예제 #1
0
def move_test(start_position):

    print("Start X:Y" + str(start_position[0]) + ":" + str(start_position[1]))
    pydirectinput.moveTo(start_position[0] + 100, start_position[1] + 100)
    time.sleep(.5)

    while 1:
        pydirectinput.moveRel(0, 100)
        pydirectinput.mouseDown()
        time.sleep(1)
        pydirectinput.mouseUp()
        time.sleep(1)

        pydirectinput.moveRel(100, 0)
        pydirectinput.mouseDown()
        time.sleep(1)
        pydirectinput.mouseUp()
        time.sleep(1)

        pydirectinput.moveRel(0, -100)
        pydirectinput.mouseDown()
        time.sleep(1)
        pydirectinput.mouseUp()
        time.sleep(1)

        pydirectinput.moveRel(-100, 0)
        pydirectinput.mouseDown()
        time.sleep(1)
        pydirectinput.mouseUp()
        time.sleep(1)

        print("Loop")
        time.sleep(1)
예제 #2
0
def antiafk():
    while True:
        if smitecheck() is True:
            for i in range(4):
                sleep(10)
                dualimgscan('smite', .8, False, 'close', .8, False)
                if img2 != None:
                    sleep(.5)
                    click(img2)
                    sleep(1)
                    click(playagainclick)
                    return
                elif img != None and img2 == None:
                    sleep(.5)
                    click(playagainclick)
                    return
            raise SMITERROR
        else:
            pydirectinput.moveTo(randommouse())
            singlekeypress('w', 20)
            sleep(.2)
            singlekeypress('s', 7)
            sleep(.2)
            pyautogui.press(' ')
            sleep(1.2)
            singlekeypress('b', .1)
            sleep(25)
            pyautogui.typewrite(random.choice(vgs), interval=.25)
예제 #3
0
파일: bot.py 프로젝트: TerroFlys/hsb
def reset_game(windowPos):
    #windowPos[0] = windowPos[0] + 960
    #windowPos[1] = windowPos[1] + 540 #sets positions to the middle of the screen
    print("Clicking the screen")
    pg.click(windowPos[0] + 10, windowPos[1]) # clicking next to the logo
    sleep(0.1)
    pg.moveRel(0, 50, 1)
    sleep(0.2 + (randint(0,1000)/10000))
    print("Pressing escape down")
    pdi.keyDown('esc')
    sleep(0.1 + (randint(0,1000)/10000))
    print("releasing escape")
    pdi.keyUp('esc')
    sleep(1)
    #Single Player  Testing here
    try:
        loc = pg.locateCenterOnScreen(images_path + images["restart"])
    except Exception as e:
        raise
        print("Did not find single player reset button.")
        try:
            loc = pg.locateCenterOnScreen(images_path + images["reset"])
        except Exception as e:
            raise
            print("Did not find Online reset button. Closing...")
            sys.exit(0)
    print("Clicking reset")
    pdi.moveTo(loc[0],loc[1], 0.2)
    autopy.mouse.click()
    sleep(0.2)
    autopy.mouse.click()
    print('waiting for reset to complete (' + str(rs_wait) + ' seconds)')
    sleep(rs_wait)
예제 #4
0
def mouse_return_accuracy():
    # when the mouse is moved relative, and then reversed relative again, confirm
    # that the cursor returns to the same position
    pydirectinput.moveTo(300, 300)
    time.sleep(1)
    pydirectinput.move(100, 0)
    time.sleep(1)
    pydirectinput.move(-100, 0)
예제 #5
0
def relative_mouse():
    pydirectinput.moveRel(0, 400, relative=True)
    time.sleep(1)
    pydirectinput.moveRel(0, -400, relative=True)
    time.sleep(1)
    pydirectinput.moveRel(-50, -50, relative=True)
    time.sleep(3)
    pydirectinput.moveTo(1150, 0, relative=True)
 def step(self, action, prev_action):
     print(f"action: {action}")
     print(f"Mouse Action: {MouseActionSpace[action[1]]}")
     upgrade = random.randrange(1, 9)
     pydirectinput.press(str(upgrade))
     pydirectinput.keyUp(ActionSpace[prev_action[0]])
     pydirectinput.keyDown(ActionSpace[action[0]])
     pydirectinput.moveTo(MouseActionSpace[action[1]][0],
                          MouseActionSpace[action[1]][1])
예제 #7
0
def clicks_and_typing():
    pydirectinput.moveTo(500, 300)
    time.sleep(1)
    pydirectinput.click(500, 400)
    pydirectinput.keyDown('g')
    time.sleep(0.05)
    pydirectinput.keyUp('g')
    time.sleep(0.05)
    pydirectinput.press(['c', 'v', 't'])
    time.sleep(0.05)
    pydirectinput.typewrite('myword')
예제 #8
0
def trace_square():
    # trace a box with the mouse movement
    pydirectinput.moveTo(300, 300)
    time.sleep(1)
    pydirectinput.moveTo(400, 300)
    time.sleep(1)
    pydirectinput.moveTo(400, 400)
    time.sleep(1)
    pydirectinput.moveTo(300, 400)
    time.sleep(1)
    pydirectinput.moveTo(300, 300)
예제 #9
0
def autoq():

    pic = pyautogui.screenshot(region=(320, 150, 1280, 768))
    width, height = pic.size

    for x in range(0, width, 5):
        for y in range(0, height, 5):
            r, g, b = pic.getpixel((x, y))
            if b == 90 and g == 101 and r == 206:
                pydirectinput.moveTo(x + 330, y + 160)
                pydirectinput.press('q')
                break
예제 #10
0
def handle_mouse_client(connection: socket.socket, address: tuple) -> None:
    while True:
        data = receive_data_from_client(connection,
                                        address,
                                        final_character='|')
        if data == DISCONNECT_MESSAGE:
            break
        else:
            x, y = data.split(',')
            x = int(x)
            y = int(y)
            log('mouse data received', (x, y))
            pydirectinput.moveTo(x, y)
예제 #11
0
def replay_state(state):
    global keys_state
    global mouse_state

    for i in range(len(key_str)):
        if state[i] != keys_state[key_str[i]]:
            pydirectinput.keyUp(
                key_str[i]) if state == 0 else pydirectinput.keyDown(
                    key_str[i])
            keys_state[key_str[i]] = state[i]

    mouse_state[0:2] = [
        mouse_state[0] + 10 * int(state[-2]),
        mouse_state[1] + 10 * int(state[-1])
    ]
    mouse_state[2:4] = state[-2:]
    pydirectinput.moveTo(mouse_state[0], mouse_state[1])
예제 #12
0
def click(x, y, speed=.5, seconds=1):
    time.sleep(speed)
    pydirectinput.moveTo(x, y, 0.01)
    time.sleep(0.01)
    pydirectinput.moveTo(x - 5, y - 5, 0.01)
    time.sleep(0.01)
    pydirectinput.moveTo(x + 5, y + 5, 0.01)
    time.sleep(0.01)
    pydirectinput.moveTo(x - 5, y + 5, 0.01)
    time.sleep(0.01)
    pydirectinput.click(x=x, y=y, duration=seconds)
    print('Clicked ', (x, y))
예제 #13
0
    def add_friend(self, friend_name="Helen Alfcgdeggbcih Vijayvergiyasen"):
        # Possible exceptions - Name doesn't exist; Already added as a friend

        time.sleep(6)
        search_bar = self.driver.find_element_by_xpath(self.search_bar_xpath)
        search_bar.click()
        search_bar.send_keys(friend_name)
        pydirectinput.moveTo(100, 150)
        time.sleep(1)
        pydirectinput.moveTo(120, 250)
        pydirectinput.click()
        time.sleep(6)
        friend = self.driver.find_element_by_xpath(
            '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div/div/div/div[1]/div/div/div/div/div/div[1]/div/div/div/div/div[2]/div/div[1]/h2/span/span/div/a'
        )
        friend.click()
        time.sleep(3)
        add_friend = self.driver.find_element_by_xpath(
            '/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div[1]/div/div/div[3]/div/div/div/div[2]/div/div/div/div[3]/div/span/div'
        )
        add_friend.click()
        time.sleep(6)
예제 #14
0
    # load demo
    end_image_path = pathlib.Path(args.end_image)
    console_text_entry_path = end_image_path.parent / 'console_text_entry.png'
    try:
        console_text_entry_location = pyautogui.locateOnScreen(
            str(console_text_entry_path), confidence=0.9)
    except pyautogui.ImageNotFoundException:
        print("couldn't find console text entry")
        quit(1)
    if console_text_entry_location is None:
        print("couldn't find console text entry")
        quit(1)
    pydirectinput.moveTo(
        int(console_text_entry_location.left +
            console_text_entry_location.width / 3),
        int(console_text_entry_location.top +
            console_text_entry_location.height / 2))
    pyautogui.click()
    pyautogui.write(f'''exec {config}\n''')

    time.sleep(40)

    # run post load configs
    pydirectinput.press('`')
    pyautogui.write(f'''exec {match_prefix}_post_load_{team_number}\n''')

    time.sleep(3)

    # move demoui to top left corner
    demo_playback_name_path = end_image_path.parent / 'demo_playback_name.png'
예제 #15
0
def healAndUp():
    for i in range(0, 3):
        #use health potion
        pydirectinput.press("1")
        #pick up item
        pydirectinput.press("`")


while 1:
    pydirectinput.keyDown("space")
    for i in range(len(keys)):
        pydirectinput.keyDown("space")
        #Turning
        pydirectinput.press(keys[i])
        healAndUp()
    healAndUp()

    #AntyBOT {
    pydirectinput.moveTo(1000, 1000)
    time.sleep(0.5)
    pydirectinput.moveTo(795, 597)
    pydirectinput.click()
    #}
    now = int(time.time())

    #Use hood every 30s
    if now - was >= 30:
        was = int(time.time())
        pydirectinput.press("2")
예제 #16
0
def alternate_bs(nw_with_drop):
    #prepare ingredients
    open_stand()
    nw_coords, ingredient1, ingredient2, ingredient3 = get_ingredients()
    exit_bs()
    coords = [nw_coords, ingredient1, ingredient2, ingredient3]
    if nw_coords == -1 or ingredient1 == -1 or ingredient2 == -1 or ingredient3 == -1:
        print("No ingredients!")
        return
    for k in range(11):
        error = 0
        for j, coord in enumerate(coords):
            if j == 0 and nw_with_drop:
                continue
            i = 1
            while i < 6:
                while not open_stand() and error < 30:
                    error += 1
                    if i % 5 == 0:
                        pydirectinput.moveRel(-3, 0)
                    else:
                        pydirectinput.moveRel(3, 0)
                    print("trying to find brewing stand...")
                while not ready() and error < 30:
                    print("waiting to finish brewing!")
                    time.sleep(2)
                if error >= 30:
                    return
                if j == 0:
                    first = True
                else:
                    first = False
                reset_mouse()
                print(coord)
                serve_brewing_stand(coord, first)
                exit_bs()
                time.sleep(0.1)
                if i % 5 == 0:
                    print(i)
                    pydirectinput.moveTo(399, 334)
                    pydirectinput.moveTo(401, 334)
                    pydirectinput.moveRel(-390, 0)
                    pydirectinput.moveRel(-130, 0)
                    print("moved 780")
                else:
                    pydirectinput.moveTo(401, 334)
                    pydirectinput.moveTo(399, 334)
                    pydirectinput.moveRel(130, 0)
                #time.sleep(0.1)
                i += 1
        print("ready to drop potions")
        i = 1
        while i < 6:
            open_stand()
            while not ready():
                print("waiting to finish brewing!")
                time.sleep(1)
            drop_potions()
            add_ingredient(nw_coords)
            nw_with_drop = True
            exit_bs()
            time.sleep(0.1)
            if i % 5 == 0:
                pydirectinput.moveTo(399, 334)
                pydirectinput.moveTo(401, 334)
                pydirectinput.moveRel(-390, 0)
                pydirectinput.moveRel(-130, 0)
                #reset screen
                reset_pos = pyautogui.locateOnScreen(
                    './images/reseting_screen_5.png',
                    region=(0, 40, 800, 640),
                    confidence=0.6)
                if reset_pos:
                    print("reseting screen!")
                    print(reset_pos)
                    #pydirectinput.moveTo(reset_pos[0]+135, reset_pos[1]+256)
                    pydirectinput.moveTo(reset_pos[0] + 77, reset_pos[1] + 249)
            else:
                pydirectinput.moveTo(401, 334)
                pydirectinput.moveTo(399, 334)
                pydirectinput.moveRel(130, 0)
            time.sleep(0.2)
            i += 1
    return nw_with_drop
 def move_to(self, x, y, duration=None):
     auto_input.moveTo(x, y, duration)
예제 #18
0
def move_piece(old_x, old_y, new_x, new_y):
    old_coordinate = convert_offset_to_window_offset((old_x, old_y))
    new_coordinate = convert_offset_to_window_offset((new_x, new_y))

    print("OLD: old_x:{}, old_y:{}. new_x:{}, new_y:{}".format(
        old_x, old_y, new_x, new_y))
    """
    old_x, old_y, new_x, new_y = old_x//2, old_y//2, new_x//2, new_y//2
    print("NEW: old_x:{}, old_y:{}. new_x:{}, new_y:{}".format(old_x, old_y, new_x, new_y))
    """

    window = get_active_dos_window()
    window.activate()

    left, top, width, height = get_actual_window_coordinates(window)
    pydirectinput.moveTo(left + 20, top + 50)
    pydirectinput.moveTo(left + 20, top + 50)
    pydirectinput.moveTo(left + 20, top + 50)
    pydirectinput.moveTo(left + 20, top + 50)

    time.sleep(.5)

    move_x = left + old_coordinate[0]
    move_y = top + old_coordinate[1]

    print("move_x:{}, move_y:{}".format(move_x, move_y))

    time.sleep(.5)
    pydirectinput.moveTo(move_x, move_y)
    time.sleep(.5)
    pydirectinput.mouseDown()
    time.sleep(.5)
    pydirectinput.mouseUp()

    move_x = left + new_coordinate[0]
    move_y = top + new_coordinate[1]

    print("move_x:{}, move_y:{}".format(move_x, move_y))

    time.sleep(.5)
    pydirectinput.moveTo(move_x, move_y)
    time.sleep(.5)
    pydirectinput.mouseDown()
    time.sleep(.5)
    pydirectinput.mouseUp()
    time.sleep(.5)
예제 #19
0
def inventory_item_full_info(slot_i, slot_pos, slot_size, ss_path):
    """
    Returns a tuple follow this format : (slot_i, item_name, amount) (int, str, int)
    It uses the item_amount function

    :param slot_i: <int> Slot index
    :param slot_pos: <tuple> Format (X, Y)
    :param slot_size: <int> Slot size (needed for item_amount screenshots)
    :param ss_path: <str> Path to save screenshots (it spams them) Example : "./screenshots/"
    """
    max_length = 400
    slot_info = (slot_i, "null", "null"
                 )  #Won't be changed if no items detected

    pydirectinput.moveTo(slot_pos[0], slot_pos[1])
    screenshot = pyautogui.screenshot(f"{ss_path}slot_{slot_i}.png",\
         region=(slot_pos[0]+17,slot_pos[1]-30, max_length, 24))#Takes Screenshot

    pixel = screenshot.getpixel(
        (1, 0))  #First top left pixel indicates if we found an item
    # item names are surrounded in a pink/black box, that we use to detect if one found

    if (25 <= pixel[0] <= 45) and (0 <= pixel[1] <= 15) and (80 <= pixel[2] <=
                                                             100):
        # More or less close to (35, 0, 90) that we're looking for
        # If entered here, an item has been detected

        width = max_length - 1
        while width >= 0:
            new_px = screenshot.getpixel((width, 0))
            if (25 <= new_px[0] <= 45) and (0 <= new_px[1] <=
                                            15) and (80 <= new_px[2] <= 100):
                # Means we reached the box around item name, no extra space on the right anymore
                break
            width -= 10
        print(width)

        screenshot = pyautogui.screenshot(f"{ss_path}slot_{slot_i}.png",\
             region=(slot_pos[0]+17,slot_pos[1]-30, width, 24))#New updated screenshot
        # Better OCR as a result of cropping the image

        content = pytesseract.image_to_data(screenshot)
        # image_to_data separates all text found in words

        item_name = ''

        for x, bx in enumerate(
                content.splitlines()):  # Each line holds different data

            if x != 0:  # First line is a different format and holds no data we need
                bx = bx.split()

                if len(bx) == 12:  # len is 12 when a word is found

                    item_name += f'{bx[11]} '  # word held at index 11 (last one)

        pyautogui.moveTo(
            64, 103)  #Outside of inventory to not block item screenshot

        amount = item_amount(slot_pos,
                             slot_size,
                             f'slot_{slot_i}_amount.png',
                             ss_path=ss_path)
        # Calls item_amount to get the amount on this slot

        slot_info = (slot_i, item_name, amount)

    return slot_info
import pydirectinput
import threading
import time
import keyboard
import random
import win32api, win32con

while 1:
    mouse = Controller()
    keyboard = Controller()
    pos = imagesearch("press_f.png")
    if pos[0] != -1:
        print("position : ", pos[0], pos[1])
        press('f')
        press('f')
        press('f')

    pos = imagesearcharea("nv.png", 0, 0, 1400, 900)
    if pos[0] != -1:
        pydirectinput.moveTo(pos[0], pos[1])
        pyautogui.scroll(-10)
        pyautogui.tripleClick()
        press('e')
    #pydirectinput.moveTo(None, 30)
    #else:
    #press('w')
    #temos que separar isso daqui em outra execucao
    #keyboard.press('w')
    #time.sleep(10)
    #keyboard.release('w')
예제 #21
0
 def moveMouseAbsolute_software(self, x: int, y: int):
     pydirectinput.moveTo(x, y)
     sleep(2)
예제 #22
0
 def move_mouse(self):
     mouseX = round(self.width * (self.point.x) / self.canvas_width)
     mouseY = round(self.height * self.point.y / self.canvas_height)
     pydirectinput.moveTo(mouseX, mouseY)
예제 #23
0
def moveToRegion(location):
    pydirectinput.moveTo(int(location.left + location.width / 3),
                         int(location.top + location.height / 2))
예제 #24
0
def movePlayer():
    pydirectinput.moveTo(round(width * x / canvasWidth),
                         round(height * y / canvasHeight))
         elif reg.search(typeMsg):
             obs()
             pydirectinput.typewrite(typeMsg)
         else:
             obs()
             pydirectinput.typewrite(typeMsg)
     except:
         print("Typing this particular message didn't work: " + msg)
 if msg.startswith("go to "):
     try:
         obs()
         coord = msg[6:]
         xval, yval = coord.split(' ', 1)
         xval = int(xval)
         yval = int(yval)
         pydirectinput.moveTo(xval, yval)
     except:
         print("Typing this particular message didn't work: " + msg)
 if msg in ['select all', 'control all', 'ctrl all', 'ctrl a']:
     obs()
     PressKeyPynput(LEFT_CONTROL)
     PressAndHoldKey(A, 0.004)
     ReleaseKeyPynput(LEFT_CONTROL)
 if msg.startswith('d for '):
     try:
         timee = msg[6:]
         timee = float(timee)
         if timee <= 10 and timee >= 0:
             obs()
             PressAndHoldKey(D, timee)
     except:
예제 #26
0
    # get death and tick locations
    death_region = getRegionFromImage(state_images_path / 'just_death.png',
                                      "death selector")
    tick_image = Image.open(state_images_path / 'tick_no_death.png')
    tick_width, tick_height = tick_image.size

    # get resume button location
    resume_path = state_images_path / 'just_resume.png'
    resume_region = getRegionFromImage(resume_path, "just resume button")

    # start playback and recording
    pydirectinput.press('`')
    moveToRegion(resume_region)
    pydirectinput.click()
    pydirectinput.moveTo(30, 30)
    pydirectinput.press('F1')

    # wait until end of snippet
    while True:
        tick = getTick(death_region, tick_width, tick_height, tessocr_api)
        print(f'''Read tick {tick}''')
        # skip invalid or misread ticks
        if tick is None or tick > 5 * row['end_game_tick']:
            misread_ticks += 1
            if misread_ticks >= 30:
                quit(1)
            continue
        if tick > row['end_game_tick'] + offset:
            misread_ticks = 0
            break
예제 #27
0
def moveMouse():
    # print("hi?")
    pydirectinput.moveTo(round(width * (x3) / canvasWidth),
                         round(height * y3 / canvasHeight))
예제 #28
0
def smooth_mouse(point, steps):
    for i in range(steps):
        pydi.moveTo(point[0]+(steps-i), point[1]+(steps-i))
예제 #29
0
    def runHack(self):
        
        crop_image = self.get_image()

        timep = 0.2

        if self.state == 0:
            mouse_x = int(self.PUZZLE_GET_NEW_PIECE[0] + self.PUZZLE_WINDOW_POSITION[0] + self.wincap.offset_x)
            mouse_y = int(self.PUZZLE_GET_NEW_PIECE[1] + self.PUZZLE_WINDOW_POSITION[1] + self.wincap.offset_y)

            if time() - self.timer_action > timep:

                if self.detect_end_game(crop_image):
                    self.botting = False
                    return None

                pydirectinput.click(x=mouse_x, y=mouse_y, button='left')
                self.state = 1
                self.timer_action = time()

        if self.state == 1:

            if time() - self.timer_action > timep:
                self.press_comfirm()
                self.state = 2
                self.timer_action = time()

        if self.state == 2:

            mouse_x = int(self.PUZZLE_GET_NEW_PIECE_COLOR[0] + self.PUZZLE_WINDOW_POSITION[0] + self.wincap.offset_x)
            mouse_y = int(self.PUZZLE_GET_NEW_PIECE_COLOR[1] + self.PUZZLE_WINDOW_POSITION[1] + self.wincap.offset_y)

            if time() - self.timer_action > timep:
                self.state = 4
                self.timer_action = time()
                pydirectinput.moveTo(mouse_x, mouse_y)

        if self.state == 4:

            if time() - self.timer_action > timep:
                self.state = 5
                self.timer_action = time()
                self.new_piece = self.get_new_piece_color(crop_image)

        if self.state == 5:
            if time() - self.timer_action > timep:
                self.timer_action = time()
                self.set_puzzle_state(crop_image)
                if self.play_game():
                    self.state = 6
                else:
                    self.state = 7
                
        if self.state == 6:
            if time() - self.timer_action > timep:
                self.press_comfirm()
                self.timer_action = time()
                if self.end:
                    self.state = 9
                else: 
                    self.state = 0

        if self.state == 7:
            if time() - self.timer_action > timep:
                self.throw_pice()
                self.timer_action = time()
                self.state = 8

        if self.state == 8:
            if time() - self.timer_action > timep:
                self.press_comfirm()
                self.timer_action = time()
                self.state = 0

        if self.state == 9:
            if time() - self.timer_action > 2:
                self.end = False
                self.press_comfirm_cake()
                self.timer_action = time()
                self.state = 0

        return None
예제 #30
0
 def mmove(self, x, y):
     # self.mouse_control.position = (x, y)
     pydirectinput.moveTo(x, y)