python类click()的实例源码

click_beta.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
drag.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
drag.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
scroll.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
scroll.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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'.
switch.py 文件源码 项目:Manimouse 作者: shivamkajale 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
.Trouble.py 文件源码 项目:Cool-Scripts 作者: Anishka0107 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def behaviour2() :
    pyautogui.click (500, 200)
    pyautogui.dragRel (100, 500, duration = 0.27)
    pyautogui.doubleclick()
    pyautogui.scroll (600)
    pyautogui.rightclick()
dino_api.py 文件源码 项目:go_dino 作者: pauloalves86 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:input-paste 作者: RPing 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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()
run.py 文件源码 项目:dotabots-ml-tools 作者: ThePianoDentist 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
run.py 文件源码 项目:dotabots-ml-tools 作者: ThePianoDentist 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
run.py 文件源码 项目:dotabots-ml-tools 作者: ThePianoDentist 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
run.py 文件源码 项目:dotabots-ml-tools 作者: ThePianoDentist 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def presskey_1(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("1", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def presskey_2(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("2", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def presskey_3(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("3", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def presskey_3(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("4", interval=0.1)

            #num keys only for now
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def presskey_q(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("q", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def presskey_e(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("e", interval=0.1)


问题


面经


文章

微信
公众号

扫码关注公众号