Exemple #1
0
def skill_macro(keys, delays):
    global is_running
    global timers
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    print(is_running)
    if handle and not is_running:
        is_running = True
        for i, (hotkey, delay) in enumerate(zip(keys, delays)):
            if hotkey and delay:
                if i < 4:
                    timers.append(
                        RepeatedTimer(delay / 100,
                                      lambda x=hotkey: send_key(handle, x)))
                elif i == 4:
                    # ggf. press shift
                    x, y = win32gui.ScreenToClient(handle,
                                                   win32api.GetCursorPos())
                    timers.append(
                        RepeatedTimer(delay / 100,
                                      lambda: send_mouse(handle, 'LM', x, y)))
                elif i == 5:
                    x, y = win32gui.ScreenToClient(handle,
                                                   win32api.GetCursorPos())
                    timers.append(
                        RepeatedTimer(delay / 100,
                                      lambda: send_mouse(handle, 'RM', x, y)))
        [t.start() for t in timers]
    elif is_running:
        [t.stop() for t in timers]
        timers = []
        is_running = False
Exemple #2
0
def leave_game():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        leave = transform_coordinates(handle, 230, 475)

        send_key(handle, 'esc')
        send_mouse(handle, 'LM', leave[0], leave[1])
Exemple #3
0
def open_rift():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        rift = transform_coordinates(handle, 270, 300)
        accept = transform_coordinates(handle, 260, 850)

        send_mouse(handle, 'LM', rift[0], rift[1])
        send_mouse(handle, 'LM', accept[0], accept[1])
Exemple #4
0
def start_game(screenshot, handle):
    x1, y1, x2, y2 = win32gui.GetClientRect(handle)
    img_to_find = os.path.join(wd,
                               f'./images/{x2 - x1}_{y2 - y1}/start_game.png')
    x1, y1 = transform_coordinates(handle, 160, 500)
    x2, y2 = transform_coordinates(handle, 320, 540)
    img = crop_image(screenshot, x1, y1, x2, y2)
    if image_search(img_to_find, img, precision=0.8):
        print('FOUND START GAME!')
        send_mouse(handle, 'LM', x1, y1)
Exemple #5
0
def lower_difficulty():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        lower = transform_coordinates(handle, 1700, 400, rel='right')

        send_key(handle, 'esc')
        for i in range(19):
            send_mouse(handle, 'LM', lower[0], lower[1])
            send_key(handle, 'enter')
        send_key(handle, 'esc')
Exemple #6
0
def accept_gr(screenshot, handle):
    x1, y1, x2, y2 = win32gui.GetClientRect(handle)
    img_to_find = os.path.join(wd,
                               f'./images/{x2 - x1}_{y2 - y1}/keystone.png')
    x1, y1 = transform_coordinates(handle, 705, 755)
    x2, y2 = transform_coordinates(handle, 790, 815)
    accept = transform_coordinates(handle, 800, 900)
    img = crop_image(screenshot, x1, y1, x2, y2)
    if image_search(img_to_find, img, precision=0.8):
        print('FOUND accept GR')
        send_mouse(handle, 'LM', accept[0], accept[1])
Exemple #7
0
def gamble(item):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        tab_coords = kadala_tab_by_name(item)
        item_coords = kadala_item_by_name(item)
        tab = transform_coordinates(handle, tab_coords[0], tab_coords[1])
        item = transform_coordinates(handle, item_coords[0], item_coords[1])

        send_mouse(handle, 'LM', tab[0], tab[1])
        for i in range(60):
            send_mouse(handle, 'RM', item[0], item[1])
Exemple #8
0
def drop_inventory(spare_columns):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        item = transform_coordinates(handle, 1875, 585, rel='right')
        step = transform_coordinates(handle, 50, 50)
        x, y = win32gui.ScreenToClient(handle, win32api.GetCursorPos())

        send_key(handle, 'c')
        for i in range(6):
            for j in range(10 - spare_columns):
                send_mouse(handle, 'LM', item[0] - j * step[0], item[1] + i * step[1])
                send_mouse(handle, 'LM', x, y)
        send_key(handle, 'c')
Exemple #9
0
def swap_armor(items):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        item_coords = []
        for i in range(items):
            item_coords.append(
                transform_coordinates(handle, 1425, 580 + i * 100,
                                      rel='right'))

        send_key(handle, 'c')
        for i, coords in enumerate(item_coords):
            if i == 1:
                send_key_down(handle, 'alt')
                send_mouse(handle, 'RM', coords[0], coords[1])
                send_key_up(handle, 'alt')
            else:
                send_mouse(handle, 'RM', coords[0], coords[1])
        send_key(handle, 'c')
Exemple #10
0
def upgrade_gem(empowered, choose_gem):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        upgrade = transform_coordinates(handle, 280, 550)

        if not choose_gem:
            first_gem = transform_coordinates(handle, 100, 640)
            send_mouse(handle, 'LM', first_gem[0], first_gem[1])
            sleep(0.1)
        try:
            if not empowered:
                for i in range(4):
                    print("gemup " + str(i))
                    if i == 3:
                        send_key(handle, 't')
                    send_mouse(handle, 'LM', upgrade[0], upgrade[1])
                    macro_sleep(1.8)
            else:
                for i in range(5):
                    print("gemup emp " + str(i))
                    if i == 4:
                        send_key(handle, 't')
                    send_mouse(handle, 'LM', upgrade[0], upgrade[1])
                    macro_sleep(1.8)
        except StopMacro:
            pass
Exemple #11
0
def upgrade_gem(screenshot, handle):
    x1, y1, x2, y2 = win32gui.GetClientRect(handle)
    uhrsi = os.path.join(wd, f'./images/{x2 - x1}_{y2 - y1}/urhsi.png')
    x1, y1 = transform_coordinates(handle, 220, 30)
    x2, y2 = transform_coordinates(handle, 300, 100)
    img = crop_image(screenshot, x1, y1, x2, y2)
    if image_search(uhrsi, img, precision=0.8):
        x1, y1, x2, y2 = win32gui.GetClientRect(handle)
        images_to_find = [
            os.path.join(
                wd, f'./images/{x2 - x1}_{y2 - y1}/urhsi_upgrade_{i}.png')
            for i in range(1, 6)
        ]
        x1, y1 = transform_coordinates(handle, 270, 530)
        x2, y2 = transform_coordinates(handle, 355, 560)
        upgrade = transform_coordinates(handle, 280, 550)

        upgrade_img = crop_image(screenshot, x1, y1, x2, y2)

        if image_search(images_to_find[4], upgrade_img, precision=0.95):
            send_mouse(handle, 'LM', upgrade[0], upgrade[1])
            print('Found 5 Upgrades left!')
        elif image_search(images_to_find[3], upgrade_img, precision=0.95):
            send_mouse(handle, 'LM', upgrade[0], upgrade[1])
            print('Found 4 Upgrades Left!')
        elif image_search(images_to_find[2], upgrade_img, precision=0.95):
            send_mouse(handle, 'LM', upgrade[0], upgrade[1])
            #send_key(handle, 't')
            print('Found 3 Upgrades Left!')
        elif image_search(images_to_find[1], upgrade_img, precision=0.95):
            send_mouse(handle, 'LM', upgrade[0], upgrade[1])
            send_key(handle, 't')
            print('Found 2 Upgrades Left!')
        elif image_search(images_to_find[0], upgrade_img, precision=0.95):
            send_mouse(handle, 'LM', upgrade[0], upgrade[1])
            send_key(handle, 't')
            print('Found 1 Upgrades Left!')
Exemple #12
0
def salvage(spare_columns):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        menu = transform_coordinates(handle, 517, 480)
        anvil = transform_coordinates(handle, 165, 295)
        item = transform_coordinates(handle, 1875, 585, rel='right')
        step = transform_coordinates(handle, 50, 50)

        send_mouse(handle, 'LM', menu[0], menu[1])  # Salvage Menu
        send_mouse(handle, 'LM', anvil[0], anvil[1])  # Click Salvage Button
        for i in range(6):
            for j in range(10 - spare_columns):
                send_mouse(handle, 'LM', item[0] - j * step[0], item[1] + i * step[1])
                send_key(handle, 'enter')
                send_key(handle, 'enter')
        send_key(handle, 'esc')
Exemple #13
0
def port_town(act):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        act_coords = map_act_coords_by_act(act)
        town_coords = map_town_coords_by_act(act)

        bw_map = transform_coordinates(handle, 895, 125, rel='middle')
        act = transform_coordinates(handle, act_coords[0], act_coords[1], rel='middle')
        town = transform_coordinates(
            handle, town_coords[0], town_coords[1], rel='middle'
        )

        send_key(handle, 'm')
        send_mouse(handle, 'LM', bw_map[0], bw_map[1])
        send_mouse(handle, 'LM', act[0], act[1])
        send_mouse(handle, 'LM', town[0], town[1])
Exemple #14
0
def port_pool(poolspotlist):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        poolspot = poolspotlist.next_spot()
        if poolspot:
            bw_map = transform_coordinates(handle, 895, 125, rel='middle')
            act = transform_coordinates(
                handle, poolspot[0][0], poolspot[0][1], rel='middle'
            )
            wp = transform_coordinates(
                handle, poolspot[1][0], poolspot[1][1], rel='middle'
            )

            # send_key(handle, 'm')
            send_mouse(handle, 'LM', bw_map[0], bw_map[1])
            send_mouse(handle, 'LM', act[0], act[1])
            send_mouse(handle, 'LM', wp[0], wp[1])
Exemple #15
0
def tpA2Temple():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        # open map
        send_key(handle, 'm')
        sleep(0.2)
        # reduce map
        map = transform_coordinates(handle, 895, 130)
        send_mouse(handle, 'LM', map[0], map[1])
        sleep(0.2)
        # select A2
        map = transform_coordinates(handle, 1090, 520)
        send_mouse(handle, 'LM', map[0], map[1])
        sleep(0.2)
        # select temple bounty
        map = transform_coordinates(handle, 1430, 380)
        send_mouse(handle, 'LM', map[0], map[1])
Exemple #16
0
def tpa1HoA1():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        # open map
        send_key(handle, 'm')
        sleep(0.2)
        # reduce map
        map = transform_coordinates(handle, 895, 130)
        send_mouse(handle, 'LM', map[0], map[1])
        sleep(0.2)
        # select A1
        map = transform_coordinates(handle, 740, 620)
        send_mouse(handle, 'LM', map[0], map[1])
        sleep(0.2)
        # select HoA1
        map = transform_coordinates(handle, 467, 380)
        send_mouse(handle, 'LM', map[0], map[1])
Exemple #17
0
def cube_conv_sm(speed):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        item = transform_coordinates(handle, 1425, 580, rel='right')
        step = transform_coordinates(handle, 50, 50)
        fill = transform_coordinates(handle, 710, 840)
        trans = transform_coordinates(handle, 250, 830)
        bw = transform_coordinates(handle, 580, 850)
        fw = transform_coordinates(handle, 850, 850)

        try:
            if speed == 'normal':
                for i in range(6):
                    for j in range(10):
                        send_mouse(handle, 'RM', item[0] + j * step[0],
                                   item[1] + i * step[1])
                        macro_sleep(0.13)
                        # macro_sleep(0.1)
                        send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
                        send_mouse(handle, 'LM', trans[0],
                                   trans[1])  # Transmute
                        macro_sleep(0.13)
                        # macro_sleep(0.1)
                        send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
                        send_mouse(handle, 'LM', fw[0], fw[1])  # Forwards
            elif speed == 'sol':
                for _ in range(2):
                    for i in range(6):
                        for j in range(10):
                            send_mouse(
                                handle,
                                'RM',
                                item[0] + j * step[0],
                                item[1] + i * step[1],
                            )
                            macro_sleep(0.06)  # 0.025
                            send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
                            send_mouse(handle, 'LM', trans[0],
                                       trans[1])  # Transmute
                            macro_sleep(0.06)  # 0.025
                            send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
                            send_mouse(handle, 'LM', fw[0], fw[1])  # Forwards
            elif speed == 'slow':
                for i in range(6):
                    for j in range(10):
                        send_mouse(handle, 'RM', item[0] + j * step[0],
                                   item[1] + i * step[1])
                        macro_sleep(0.13)
                        send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
                        macro_sleep(0.1)
                        send_mouse(handle, 'LM', trans[0],
                                   trans[1])  # Transmute
                        macro_sleep(0.13)
                        send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
                        macro_sleep(0.1)
                        send_mouse(handle, 'LM', fw[0], fw[1])  # Forwards
            elif speed == 'extra_slow':
                for i in range(6):
                    for j in range(10):
                        send_mouse(handle, 'RM', item[0] + j * step[0],
                                   item[1] + i * step[1])
                        macro_sleep(0.26)
                        send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
                        macro_sleep(0.2)
                        send_mouse(handle, 'LM', trans[0],
                                   trans[1])  # Transmute
                        macro_sleep(0.26)
                        send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
                        macro_sleep(0.2)
                        send_mouse(handle, 'LM', fw[0], fw[1])  # Forwards
        except StopMacro:
            pass
Exemple #18
0
def left_click(hotkey):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        x, y = win32gui.ScreenToClient(handle, win32api.GetCursorPos())
        send_mouse(handle, 'LM', x, y)
        sleep(0.003)
Exemple #19
0
def reforge():
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')
    if handle:
        item = transform_coordinates(handle, 1425, 580, rel='right')
        fill = transform_coordinates(handle, 710, 840)
        trans = transform_coordinates(handle, 250, 830)
        bw = transform_coordinates(handle, 580, 850)
        fw = transform_coordinates(handle, 850, 850)

        send_mouse(handle, 'RM', item[0], item[1])  # Item
        sleep(0.1)
        send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
        send_mouse(handle, 'LM', trans[0], trans[1])  # Transmute
        sleep(0.1)
        send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
        send_mouse(handle, 'LM', fw[0], fw[1])  # Forth
        # send_mousemove(handle, item[0], item[1])
        send_mouse(handle, 'RM', item[0], item[1])  # Item
Exemple #20
0
def reforge_primal(speed):
    handle = win32gui.FindWindow('D3 Main Window Class', 'Diablo III')

    stop = False
    nmax = 1000

    try:
        if handle:
            while not stop and nmax > 0:

                if interrupt_key():
                    break

                nmax = nmax - 1

                item = transform_coordinates(handle, 1425, 580, rel='right')
                fill = transform_coordinates(handle, 710, 840)
                trans = transform_coordinates(handle, 250, 830)
                bw = transform_coordinates(handle, 580, 850)
                fw = transform_coordinates(handle, 850, 850)

                send_mouse(handle, 'RM', item[0], item[1])  # Item
                sleepSpeedConv(speed)
                send_mouse(handle, 'LM', fill[0], fill[1])  # Fill
                sleepSpeedConv(speed)
                send_mouse(handle, 'LM', trans[0], trans[1])  # Transmute
                sleepSpeedConv(speed)
                send_mouse(handle, 'LM', bw[0], bw[1])  # Backwards
                sleepSpeedConv(speed)
                send_mouse(handle, 'LM', fw[0], fw[1])  # Forth
                sleepSpeedConv(speed)
                send_mouse(handle, 'RM', item[0], item[1])  # Item
                sleepSpeedConv(speed)
                send_mousemove(handle, item[0], item[1])  # Hover
                sleep(0.1)

                # screenshot
                screenshot = get_image(handle)
                if foundPrimal(screenshot, handle):
                    stop = True
    except StopMacro:
        pass