Python pyautogui 模块,click() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pyautogui.click()

项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def handle_cancelling_sell(runescape_window, ge_slot, list_of_items_in_use):
    # click box 2
    box_2_loc = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-254, runescape_window.bottom_right_corner[1]-165), (runescape_window.bottom_right_corner[0]-224, runescape_window.bottom_right_corner[1]-139))
    realmouse.move_mouse_to(box_2_loc[0], box_2_loc[1])
    pyautogui.click()
    # runescape_window.update_money(runescape_window.money+((ge_slot.item.quantity_to_buy-2)*ge_slot.item.price_instant_sold_at)) think this line is breaking it
    # click collect box 1
    box_1_loc = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-303, runescape_window.bottom_right_corner[1]-164), (runescape_window.bottom_right_corner[0]-273, runescape_window.bottom_right_corner[1]-139))
    realmouse.move_mouse_to(box_1_loc[0], box_1_loc[1])
    pyautogui.click()
    # if not then click box 2 and proceed to sell the item
    wait_for('Tools/screenshots/lent_item_box.png', runescape_window)
    if ge_slot.item.number_available_to_buy > 0:
        find_up_to_date_sell_price(runescape_window, ge_slot)
        ge_slot.item.set_price_instant_bought_at(ge_slot.item.price_instant_bought_at-1)
    else:
        ge_slot.item.set_price_instant_bought_at(int(ge_slot.item.price_instant_bought_at*0.98)-1)
    sell_items(runescape_window, ge_slot)
    # item didnt buy any of so we can just mark this slot as open and start again
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def wait_for(image, runescape_window):
    # adding a possible failsafe in here
    time_entered = time.time()
    # could add a failsafe in here incase we misclick or something, this
    # should be something to come back to
    failsafe_count = 0
    while(True):
        found = pyautogui.locateOnScreen(image, region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[
                                         0] - runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1] - runescape_window.top_left_corner[1]))
        if found != None:
            break
        elif failsafe_count > 10:
            print("We can't seem to fix the problem so the script is now aborting")
            quit()
        elif time.time()-time_entered > 5 :
            failsafe_count += 1
            print('We appear to be stuck so attempting to move the mouse and see if this fixes it')
            #print('For debug:')
            #print(runescape_window.bottom_right_corner[0], runescape_window.top_left_corner[0])
            #print(runescape_window.bottom_right_corner[1], runescape_window.top_left_corner[1])
            realmouse.move_mouse_to(random.randint(runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[0]), random.randint(runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[1]))
            #pyautogui.click()
            time_entered = time.time()
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def prevent_logout(top_left_corner, bottom_right_corner, runescape_window):
    seed = random.random()
    x, y = pyautogui.size()
    if seed > 0.5:  # opens up the sale history tab for 5 seconds then returns to ge tab
        while(True):
            realmouse.move_mouse_to(random.randint(0,x), random.randint(0,y))
            if len(list(pyautogui.locateAllOnScreen('Tools/screenshots/sale_history_button.png', region=(top_left_corner[0], top_left_corner[1], bottom_right_corner[0]-top_left_corner[0], bottom_right_corner[1]-top_left_corner[1]))))>0:
                move_mouse_to_box('Tools/screenshots/sale_history_button.png', top_left_corner, bottom_right_corner)
                pyautogui.click()
                time.sleep(9*random.random()+1)
                move_mouse_to_box('Tools/screenshots/grand_exchange_button.png', top_left_corner, bottom_right_corner)
                pyautogui.click()
                break
    else:  # examines the money pouch
        examine_money(bottom_right_corner)

# pass in an image and a search region
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def basic_api():
    x, y = pg.size()
    print x, y

    '''
    pg.moveTo(300,300,2)
    pg.moveTo(300,400,2)
    pg.moveTo(500,400,2)
    pg.moveTo(500,300,2)
    pg.moveTo(300,300,2)
    #pg.moveTo(300,500,2)
    '''
    # pg.click(100,100)
    word = [u'??', u'???']
    pos = [452, 321]
    pg.moveTo(pos[0], pos[1])
    pg.click()
    pg.typewrite(word[0])
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def example():
    screenWidth, screenHeight = pg.size()
    currentMouseX, currentMouseY = pg.position()
    pg.moveTo(500, 550)
    pg.click()
    pg.moveRel(None, 10)  # move mouse 10 pixels down
    pg.doubleClick()
    # pg.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad)  # use tweening/easing function to move mouse over 2 seconds.
    pg.typewrite('Hello world!', interval=0.25)  # type with quarter-second pause in between each key
    pg.press('esc')
    pg.keyDown('shift')
    pg.press(['left', 'left', 'left', 'left', 'left', 'left'])
    pg.keyUp('shift')
    pg.hotkey('ctrl', 'c')
    delta_y = 50
项目:Nightchord    作者:theriley106    | 项目源码 | 文件源码
def applyChain(file):
    p = subprocess.Popen(["audacity", "./{}".format(file)])
    time.sleep(7)
    try:
        pyautogui.click(pyautogui.locateCenterOnScreen('src/images/discard.png'))
        time.sleep(1)
        pyautogui.click(pyautogui.locateCenterOnScreen('src/images/yes.png'))
    except:
        pass

    time.sleep(1)
    if len(list(pyautogui.locateAllOnScreen('src/images/audacity_fileButton.png'))) > 1:
        pyautogui.keyDown('alt')
        pyautogui.press('f10')
        pyautogui.keyUp('alt')
    time.sleep(1)
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_fileButton.png'))
    time.sleep(2)
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_applyChain.png'))
    time.sleep(2)
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_applyToCurrentFile.png'))
    time.sleep(10)
    p.terminate()
    print('Done')
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:keepass-menu    作者:frostidaho    | 项目源码 | 文件源码
def __init__(self, n_button_clicks=2, loopquit=None):
        """Create handler that records click events.

        loopquit must be set to some callable which will quit main loop.
        n_button_clicks is the maximum number of *left* clicks that
        will be recorded.

        Hitting Escape or the right mouse button will break out of loop

        self.output stores events and is a dict of lists.
        The keys of self.output are eventtypes in Gdk.EventType
        e.g., button_rel_events = self.output[Gdk.EventType.BUTTON_RELEASE]
        """
        self.n_button_clicks = n_button_clicks
        evtype_to_cb = {
            BUTTON_RELEASE: self.handler_button_rel,
            KEY_RELEASE: self.handler_key,
        }
        super().__init__(evtype_to_cb, loopquit)
项目:chainer-dqn    作者:dsanno    | 项目源码 | 文件源码
def _process_select(self, screen):
        self.move_to(0, 0)
        time.sleep(0.1)
        for i in reversed(range(8)):
            position = self.find_image_center(screen, self.images['stage'], 70 + i % 4 * 130, 180 + i / 4 * 170, 80, 20)
            if position != None and (i == 0 or random.randint(0, 1) == 0):
                x, y = position
                self.move_to(x, y + 10)
                time.sleep(0.1)
                self.click()
                time.sleep(2)
                break
        position = self.find_image_center(screen, self.images['select_title'], 10, 16, 60, 40)
        if position == None:
            self.state = self.STATE_PLAY
            return (None, False)
        return (None, False)
项目:chainer-dqn    作者:dsanno    | 项目源码 | 文件源码
def _process_result(self, screen):
        self.move_to(0, 0)
        time.sleep(0.1)
        position = self.find_image_center(screen, self.images['select'], 460, 406, 60, 40)
        if position != None:
            x, y = position
            self.move_to(x, y)
            time.sleep(0.1)
            self.click()
            time.sleep(3)
        else:
            x, y = 410, 425
            self.move_to(x, y)
            time.sleep(0.1)
            self.click()
            time.sleep(3)
        position = self.find_image_center(screen, self.images['select_title'], 10, 16, 60, 40)
        if position != None:
            self.state = self.STATE_SELECT
        return (None, False)
项目:PYSHA    作者:shafaypro    | 项目源码 | 文件源码
def on_command_move(self, mouse_command=None):
        try:
            if mouse_command is not None:
                mouse_command = mouse_command.strip()  # remove the extra white spaces
                mouse_command = mouse_command.lower()  # Converts into lower Strings
                if mouse_command == "left":
                    self.move_left()  # move left function is called
                elif mouse_command == "right":
                    self.move_right()  # move right function is called
                elif mouse_command == "up":
                    self.move_up()  # move up function is called
                elif mouse_command == "down":
                    self.move_down()  # Move down function called
                elif mouse_command == "click":
                    self.on_click_screen()  # Clicks the specified location in the Screen
                else:
                    print("Invalid Command Mate!")
                    return  # Returns to the Place where the function was called
        except KeyboardInterrupt as Ex:
            print("Interrupted by the Keyboard keys :", Ex)
        except Exception as Ex:
            print("The following Error Occurred", Ex)  # this is the Printing of the exception
项目:PYSHA    作者:shafaypro    | 项目源码 | 文件源码
def test_check(self):
        for i in range(2):
            pyautogui.moveTo(100, 100, duration=0.25)
            pyautogui.moveTo(200, 100, duration=0.25)
            pyautogui.moveTo(200, 200, duration=0.25)
            pyautogui.moveTo(100, 200, duration=0.25)


# M_obj = MouseMove()
# M_obj.move_left()
# M_obj.move_up()
# M_obj.move_right()
# M_obj.move_down()
# M_obj.test_check() # Just for the debuggin purpose
# M_obj.on_command_move("left")
# M_obj.on_command_move("up")
# M_obj.on_command_move("right")
# M_obj.on_command_move("down")
# M_obj.on_command_move("click")
# M_obj.scroll_down()
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def handle_cancelling_buy(runescape_window, ge_slot, list_of_items_in_use):
    # click box 1
    box_1_loc = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-303, runescape_window.bottom_right_corner[1]-164), (runescape_window.bottom_right_corner[0]-273, runescape_window.bottom_right_corner[1]-139))
    realmouse.move_mouse_to(box_1_loc[0], box_1_loc[1])
    pyautogui.click()
    # runescape_window.update_money(runescape_window.money+((ge_slot.item.quantity_to_buy-2)*ge_slot.item.price_instant_sold_at)) think this line is breaking it
    # wait and check if we have jumped back to the main window, handle this
    time.sleep(3)
    if not len(list(pyautogui.locateAllOnScreen('Tools/screenshots/lent_item_box.png', region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[0]-runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1]-runescape_window.top_left_corner[1])))) > 0:
        # we have to click box 2 still so click it and handle it
        box_2_loc = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-254, runescape_window.bottom_right_corner[1]-165), (runescape_window.bottom_right_corner[0]-224, runescape_window.bottom_right_corner[1]-139))
        realmouse.move_mouse_to(box_2_loc[0], box_2_loc[1])
        pyautogui.click()
        # if not then click box 2 and proceed to sell the item
        wait_for('Tools/screenshots/lent_item_box.png', runescape_window)
        if ge_slot.item.number_available_to_buy > 0:
            find_up_to_date_sell_price(runescape_window, ge_slot)
            ge_slot.item.set_price_instant_bought_at(ge_slot.item.price_instant_bought_at-1)
        sell_items(runescape_window, ge_slot, record_number_selling=True)
        runescape_window.add_to_items_on_cooldown(ge_slot.item)
        ge_slot.item.update_number_available_to_buy(ge_slot.item.number_available_to_buy-ge_slot.item.quantity_to_buy)
        return()
    # item didnt buy any of so we can just mark this slot as open and start again
    runescape_window.update_money(runescape_window.money+((ge_slot.item.quantity_to_buy-2)*ge_slot.item.price_instant_sold_at))
    ge_slot.update_buy_or_sell_state(None)
    list_of_items_in_use.remove(ge_slot.item.item_name)
    ge_slot.item.set_price_instant_bought_at(None)
    ge_slot.item.set_price_instant_sold_at(None)
    ge_slot.set_item_in_ge_slot(None)
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def cancel_offer(top_left_corner, bottom_right_corner, runescape_window):
    loc_of_ge_point = pointfrombox.random_point(top_left_corner, bottom_right_corner)
    realmouse.move_mouse_to(loc_of_ge_point[0], loc_of_ge_point[1])
    pyautogui.click()
    # print('now waiting and then trying to locate x button')
    # wait_for('Tools/screenshots/abort_x_button.png', runescape_window)
    time.sleep(3+random.random())
    fail_count = 0
    # print('We are about to cancel an offer that we believe to be in the window with coords {}, we are at line 497'.format(runescape_window.bottom_right_corner))
    while True:
        cancel_loc = pyautogui.locateOnScreen('Tools/screenshots/abort_x_button.png', region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[0]-runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1]-runescape_window.top_left_corner[1]))
        if fail_count > 3:
            print('failed 3 times so trying to locate the abort button from the inventory collect button')
            to_inv_loc = pyautogui.locateOnScreen('Tools/screenshots/to_inv_button.png', region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[0]-runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1]-runescape_window.top_left_corner[1]))
            cancel_loc = tuple(numpy.subtract(to_inv_loc, (163, 107, 163, 8)))
        if cancel_loc == None:
            print('Failed to locate the abort button {} times, trying again in 5 seconds'.format(fail_count))
            time.sleep(5)
            fail_count += 1
        else:
            break
    # print('we have saved the location of the x button ready to click')
    # print(cancel_loc)
    point_of_cancel_button = pointfrombox.random_point((cancel_loc[0], cancel_loc[1]), (cancel_loc[0]+cancel_loc[2], cancel_loc[1]+cancel_loc[3]))
    realmouse.move_mouse_to(point_of_cancel_button[0], point_of_cancel_button[1])
    pyautogui.click()
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def collect_items_from_ge_slot(ge_slot, runescape_window):
    point_to_click = pointfrombox.random_point(ge_slot.top_left_corner, ge_slot.bottom_right_corner)
    realmouse.move_mouse_to(point_to_click[0], point_to_click[1])
    pyautogui.click()
    wait_for('Tools/screenshots/completed_offer_page.png', runescape_window)
    point_of_item_collection_box_1 = pointfrombox.random_point((runescape_window.bottom_right_corner[0] - 303, runescape_window.bottom_right_corner[
                                                               1] - 166), (runescape_window.bottom_right_corner[0] - 273, runescape_window.bottom_right_corner[1] - 138))
    point_of_item_collection_box_2 = pointfrombox.random_point((runescape_window.bottom_right_corner[0] - 254, runescape_window.bottom_right_corner[
                                                               1] - 166), (runescape_window.bottom_right_corner[0] - 222, runescape_window.bottom_right_corner[1] - 138))
    realmouse.move_mouse_to(point_of_item_collection_box_2[0], point_of_item_collection_box_2[1])
    pyautogui.click()
    realmouse.move_mouse_to(point_of_item_collection_box_1[0], point_of_item_collection_box_1[1])
    pyautogui.click()
    wait_for('Tools/screenshots/lent_item_box.png', runescape_window)
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
def examine_money(position):
    # this whole block just examines the amount of money
    point = pointfrombox.random_point((138, 94), (189, 109))
    # that the account has just for auto log out purposes
    money_pouch = (position[0] - point[0], position[1] - point[1])
    # so that it has a recording of the last time an action
    realmouse.move_mouse_to(money_pouch[0], money_pouch[1])
    # was taken and can keep track of this value in future to stop logouts
    # occuring
    pyautogui.click(button='right')
    point = pointfrombox.random_point((-75, -32), (74, -24))
    examine = (money_pouch[0] - point[0], money_pouch[1] - point[1])
    realmouse.move_mouse_to(examine[0], examine[1])
    pyautogui.click()
项目:Glidr    作者:muinmomin    | 项目源码 | 文件源码
def click():
    gui.click()
    #print 'click'
项目:Nightchord    作者:theriley106    | 项目源码 | 文件源码
def clickFile():
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_fileButton.png'))
项目:Nightchord    作者:theriley106    | 项目源码 | 文件源码
def clickApplyChain():
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_applyChain.png'))
项目:Nightchord    作者:theriley106    | 项目源码 | 文件源码
def clickApplyToFile():
    pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_applyToCurrentFile.png'))
项目:Nightchord    作者:theriley106    | 项目源码 | 文件源码
def maxWindow():
    try:
        pyautogui.click(pyautogui.locateCenterOnScreen('src/images/discard.png'))
        time.sleep(1)
        pyautogui.click(pyautogui.locateCenterOnScreen('src/images/yes.png'))
    except:
        pass

    time.sleep(1)
    if len(list(pyautogui.locateAllOnScreen('src/images/audacity_fileButton.png'))) > 1:
        pyautogui.keyDown('alt')
        pyautogui.press('f10')
        pyautogui.keyUp('alt')
项目:gmail-generator    作者:unix121    | 项目源码 | 文件源码
def open_firefox():

    # Printing basic message
    msg(1,'Opening Firefox...')

    # Location the start button
    _start_button_=pyautogui.locateOnScreen('images/start_button.png')
    _location_=pyautogui.center(_start_button_)

    # Clicking the start button
    if not  pyautogui.click(_location_):
        msg(1,'Opened start menu successfully!')
    else:
        msg(3,'Failed to open start menu!')
        ext()

    time.sleep(1)

    # Search for Firefox in the menu search
    pyautogui.typewrite('firefox')
    pyautogui.typewrite('\n')

    # Print message
    msg(1,'Firefox is now open and running.')


# Function used to locate GMail
项目:gmail-generator    作者:unix121    | 项目源码 | 文件源码
def locate_gmail():

    #Sleep for a while and wait for Firefox to open
    time.sleep(2)

    # Printing message
    msg(1,'Opening Gmail...')

    # Typing the website on the browser
    pyautogui.keyDown('ctrlleft');  pyautogui.typewrite('a'); pyautogui.keyUp('ctrlleft')
    pyautogui.typewrite('https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ltmpl=default')
    pyautogui.typewrite('\n')

    # Wait for a while until the website responds
    time.sleep(3)

    # Print a simple message
    msg(1,'Locating the form...')

    # Locate the form
    _gmail_=pyautogui.locateOnScreen('images/gmail_form.png')
    _form_=pyautogui.center(_gmail_)

    # Check and print message
    if not pyautogui.click(_form_):
        msg(1,'Located the form.')
    else:
        msg(3,'Failed to locate the form.')
        ext()


# Function used to randomize credentials
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
#           print 'dragging'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
#           print 'left click'
            return out
        elif distance(yp,rc)<40:    
            out[0] = 'right'
#           print 'right click'
            return out
        else:
#           print 'moving'
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click and dragging actions are performed here
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
#           print 'dragging'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
#           print 'left click'
            return out
        elif distance(yp,rc)<40:    
            out[0] = 'right'
#           print 'right click'
            return out
        else:
#           print 'moving'
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click and dragging actions are performed here
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def performAction( yp, rc, bc, perform):

    if perform :

        cursor[0] = 4*(yp[0]-110)
        cursor[1] = 4*(yp[1]-120)

        if yp[0]>110 and yp[0]<590 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo(cursor[0],cursor[1])
        elif yp[0]<110 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo( 8 , cursor[1])
        elif yp[0]>590 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo(1912, cursor[1])
        elif yp[0]>110 and yp[0]<590 and yp[1]<120:
            pyautogui.moveTo(cursor[0] , 8)
        elif yp[0]>110 and yp[0]<590 and yp[1]>390:
            pyautogui.moveTo(cursor[0] , 1072)
        elif yp[0]<110 and yp[1]<120:
            pyautogui.moveTo(8, 8)
        elif yp[0]<110 and yp[1]>390:
            pyautogui.moveTo(8, 1072)
        elif yp[0]>590 and yp[1]>390:
            pyautogui.moveTo(1912, 1072)
        else:
            pyautogui.moveTo(1912, 8)

        if rc[0]!=-1 and bc[0]!=-1:
            if abs(rc[0]-bc[0])<35 and abs(rc[1]-bc[1])<20:
                pyautogui.click(button = 'left')
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
            return out
        elif distance(yp,rc)<40:    
            out[0] = 'right'
            return out
        elif distance(yp,rc)>40 and rc[1]-bc[1]>120:
            out[0] = 'down'
            return out  
        elif bc[1]-rc[1]>110:
            out[0] = 'up'
            return out
        else:
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click,scroll up, scroll down
# and dragging actions are performed here based on value stored in 'action'.
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc, actionHistory):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if not leftHand and checkActionHistory( actionHistory, 'ONOFF'):
            if bc[0]-yp[0]>130 and bc[1]-yp[1]>170 and bc[1]-rc[1]<40:
                out[0] = 'ONOFF'
                return out
        elif leftHand and checkActionHistory( actionHistory, 'ONOFF'):      
            if yp[0]-bc[0]>130 and bc[1]-yp[1]>170 and bc[1]-rc[1]<40:
                out[0] = 'ONOFF'
                return out

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
            return out
        elif distance(yp,rc)<40 and checkActionHistory( actionHistory, 'right'):    
            out[0] = 'right'
            return out
        elif distance(yp,rc)>40 and rc[1]-bc[1]>120:
            out[0] = 'down'
            return out  
        elif bc[1]-rc[1]>110:
            out[0] = 'up'
            return out
        else:
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click,scroll up, scroll down
# and dragging actions are performed here based on value stored in 'action'.
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def performAction( yp, rc, bc, perform):

    if perform :

        cursor[0] = 4*(yp[0]-110)
        cursor[1] = 4*(yp[1]-120)

        if yp[0]>110 and yp[0]<590 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo(cursor[0],cursor[1])
        elif yp[0]<110 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo( 8 , cursor[1])
        elif yp[0]>590 and yp[1]>120 and yp[1]<390:
            pyautogui.moveTo(1912, cursor[1])
        elif yp[0]>110 and yp[0]<590 and yp[1]<120:
            pyautogui.moveTo(cursor[0] , 8)
        elif yp[0]>110 and yp[0]<590 and yp[1]>390:
            pyautogui.moveTo(cursor[0] , 1072)
        elif yp[0]<110 and yp[1]<120:
            pyautogui.moveTo(8, 8)
        elif yp[0]<110 and yp[1]>390:
            pyautogui.moveTo(8, 1072)
        elif yp[0]>590 and yp[1]>390:
            pyautogui.moveTo(1912, 1072)
        else:
            pyautogui.moveTo(1912, 8)

        if rc[0]!=-1 and bc[0]!=-1:
            if abs(rc[0]-bc[0])<35 and abs(rc[1]-bc[1])<20:
                pyautogui.click(button = 'left')
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
#           print 'dragging'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
#           print 'left click'
            return out
        elif distance(yp,rc)<40:    
            out[0] = 'right'
#           print 'right click'
            return out
        else:
#           print 'moving'
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click and dragging actions are performed here
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def chooseAction(yp, rc, bc):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
            return out
        elif distance(yp,rc)<40:    
            out[0] = 'right'
            return out
        elif distance(yp,rc)>40 and rc[1]-bc[1]>120:
            out[0] = 'down'
            return out  
        elif bc[1]-rc[1]>110:
            out[0] = 'up'
            return out
        else:
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click,scroll up, scroll down
# and dragging actions are performed here based on value stored in 'action'.
项目:Manimouse    作者:shivamkajale    | 项目源码 | 文件源码
def setCursorPos( yc, pyp):

    yp = np.zeros(2)

    if abs(yc[0]-pyp[0])<5 and abs(yc[1]-pyp[1])<5:
        yp[0] = yc[0] + .7*(pyp[0]-yc[0]) 
        yp[1] = yc[1] + .7*(pyp[1]-yc[1])
    else:
        yp[0] = yc[0] + .1*(pyp[0]-yc[0])
        yp[1] = yc[1] + .1*(pyp[1]-yc[1])

    return yp

# Depending upon the relative positions of the three centroids, this function chooses whether 
# the user desires free movement of cursor, left click, right click or dragging
项目:Cool-Scripts    作者:Anishka0107    | 项目源码 | 文件源码
def behaviour2() :
    pyautogui.click (500, 200)
    pyautogui.dragRel (100, 500, duration = 0.27)
    pyautogui.doubleclick()
    pyautogui.scroll (600)
    pyautogui.rightclick()
项目:go_dino    作者:pauloalves86    | 项目源码 | 文件源码
def get_game_landscape_and_set_focus_or_die(screenshotter, threshold=0.7) -> Dict:
    landscape = find_game_position(screenshotter, threshold)
    if not landscape:
        print("Can't find the game!")
        exit(1)
    pyautogui.click(landscape['left'], landscape['top'] + landscape['height'])
    return landscape
项目:input-paste    作者:RPing    | 项目源码 | 文件源码
def on_key_press(self, widget, event):
        keyname = Gdk.keyval_name(event.keyval)
        if event.state & Gdk.ModifierType.CONTROL_MASK and keyname == 'Return' or keyname == 'Return':
            self.copy_to_clipboard()
            self.destroy(self, widget)
            p = pyautogui.position()
            pyautogui.click(p)
            pyautogui.hotkey('ctrl', 'v')
        if keyname == 'Escape':
            Gtk.main_quit()
项目:dotabots-ml-tools    作者:ThePianoDentist    | 项目源码 | 文件源码
def go(self):
        run_counter = 0
        #lets you get mouse over dota
        while run_counter < self.max_runs:
            run_counter += 1
            self.run = Run(self.db.get_num_results() + 1)
            print("Hi")
            time.sleep(2.5)
            self.run.start_game()
            self.run.set_logs()  # Shouldnt matter that this occurs after game launch. I only care about logs around pull
            self.run.follow_bot()
            self.run.wait_for_pull() # ASYNCIO time?
            self.run.dump_console()
            self.run.restart()
            self.run.delay(pa.click, 282, 748, delay_secs=3)  # click the skip button
            # At this point the bot script sends the new result to database
            new_result = self.run.read_log()
            self.db.add_run(self.run.id, new_result)
            time.sleep(0.01)  # this is only because I expected game to send result to elastic search. not python
            result = Result(self.db.get_run(self.run.id))
            self.neural_net.add_result(result)
            self.neural_net.iterate_weights_2(100)
            # print(self.neural_net.weights)
            logger.info(self.neural_net)
            self.neural_net.update_params()
            #self.run.read_log()  # TODO this bit can be async whilst we are starting the next game
项目:dotabots-ml-tools    作者:ThePianoDentist    | 项目源码 | 文件源码
def launch_game(cls):
        logger.info("Launching Game")
        cls.delay(cls.click_pic, 'playdota.png')
        cls.delay(cls.click_pic, 'createlobby.png')
        cls.delay(cls.click_pic, 'startgame.png')
        cls.delay(pa.click, 282, 748, delay_secs=10)
        cls.delay(PressKey, 0x1C, delay_secs=8)
        cls.delay(ReleaseKey, 0x1C)
        cls.delay(pa.typewrite, "-startgame")
        cls.delay(PressKey, 0x1C)
        cls.delay(ReleaseKey, 0x1C)
项目:dotabots-ml-tools    作者:ThePianoDentist    | 项目源码 | 文件源码
def follow_bot(cls):
        logger.info("Clicking bot portrait to follow bot")
        # TODO have these coords depend on what slot bot is in
        pa.click(744, 103)
        pa.click(730, 927, clicks=2)
项目:dotabots-ml-tools    作者:ThePianoDentist    | 项目源码 | 文件源码
def click_pic(cls, picname):
        coords = cls.get_coords_pic(picname)
        if not coords:
            raise Exception("Could not find button")
        pa.moveTo(coords)
        time.sleep(2)
        pa.click(coords)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_1(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("1", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_2(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("2", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_3(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("3", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_3(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("4", interval=0.1)

            #num keys only for now
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_q(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("q", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_e(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("e", interval=0.1)