python类position()的实例源码

realmouse.py 文件源码 项目:RunescapeBots 作者: lukegarbutt 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def move_mouse_to(x, y):
    """Function to simulate realistic mouse movements in python. The objective of this
     will be to take in coordinates x,y and move them in a realistic manner. We
     will be passing in an x,y,  that is already 'random' so this function will
     move to the exact x,y"""
    # takes current mouse location and stores it
    while(True):
        try:
            curr_x, curr_y = pyautogui.position()
            # calculates the distance from current position to target position
            distance = int(((x - curr_x)**2 + (y - curr_y)**2)**0.5)
            # calculates a random time to make the move take based on the distance
            duration_of_move = (distance * random.random() / 2000) + 0.5
            # move the mouse to our position and takes the time of our duration just
            # calculated
            pyautogui.moveTo(x, y, duration_of_move, pyautogui.easeInOutQuad)
            #pyautogui.moveTo(x, y, duration_of_move, pyautogui.easeOutElastic)
            break
        except:
            print('paused for 10 seconds')
            time.sleep(10)
mouse_simulation_test.py 文件源码 项目:base_function 作者: Rockyzsu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
realmouse.py 文件源码 项目:RunescapeBots 作者: lukegarbutt 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def move(xe, ye, button):
    global mouseSpeed

    if button != (1 or 2):
        return

    ms = mouseSpeed
    randSpeed = (random.randrange(mouseSpeed) / 2.0 + mouseSpeed) / 10.0
    # get Cur mouse position
    xs,ys = pyautogui.position()

    humanWindMouse(xs, ys, xe, ye, 1, 5, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed)
    mouseSpeed = ms
    # click here.  Add Code
mouse_simulation_test.py 文件源码 项目:base_function 作者: Rockyzsu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_pos():
    cur_x, cur_y = pg.position()
    print cur_x, cur_y
input_paste.py 文件源码 项目:input-paste 作者: RPing 项目源码 文件源码 阅读 27 收藏 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()
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def presskey_1(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("1", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 25 收藏 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 项目源码 文件源码 阅读 40 收藏 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 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def presskey_e(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("e", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def presskey_r(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("r", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def presskey_t(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("t", interval=0.1)
keyboard.py 文件源码 项目:repo 作者: austinHeisleyCook 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def presskey_u(self):
        x = pyauotgui.position()
        pyautogui.click(x)
        pyautogui("u", interval=0.1)
autoclick1.1.py 文件源码 项目:autoclicker 作者: nkoeppel 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def startClick(self, event):
        if self.running == 0 and not (self.leftclick == 0 and self.middleclick==0 and self.rightclick == 0):
            self.running = 1
            event.widget.config(text="Stop")
            currentMouseX, currentMouseY = pyautogui.position()
            pyautogui.moveTo(currentMouseX, currentMouseY+50)
            threading.Thread(target=self.startLoop, args=()).start()
        else:
            self.running = 0
            event.widget.config(text="Start")
        time.sleep(0.2)
        return
Mouse.py 文件源码 项目:osrmacro 作者: jjvilm 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def moveTo(x,y):
    startCoords = (pyautogui.position())
    endCoords = (x, y)

    mouseCalc = MouseMovementCalculator(3, 3, mouseSpeed, 10 * mouseSpeed)
    coordsAndDelay = mouseCalc.calcCoordsAndDelay(startCoords, endCoords)

    pyautogui.moveTo(startCoords[0], startCoords[1])

    for x, y, delay in coordsAndDelay:
        delay = delay / 10000
        delay += random.random()
        pyautogui.moveTo(x, y)
        #time.sleep(delay)
Mouse.py 文件源码 项目:osrmacro 作者: jjvilm 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def mouse_loc():
    return pyautogui.position()
AutoClick.py 文件源码 项目:PyKinectTk 作者: Qirky 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def fromPosition():
        raw_input("Hover over the location you want to click and press enter")
        return position()
AutoClick.py 文件源码 项目:PyKinectTk 作者: Qirky 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def run(self):
        while self.running:
            self.click()
            sleep(self.time_step)
            if (self.x, self.y) != position():
                self.running=False
mm.py 文件源码 项目:PYSHA 作者: shafaypro 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_positions(self):
        x, y = pyautogui.position()  # this returns a tupple as in the x and the y
        return x, y
screenshot_tool.py 文件源码 项目:RunescapeBots 作者: lukegarbutt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def take_screenshot():
    file_name = 'screenshots/' + input("What would you like to save the screenshot as? Please enter the entire file name including extension, ie .png\n")
    input("Place curser over the top left corner of the box you'd like to screenshot and press enter")
    top_left = pyautogui.position()
    input("Place curser over the bottom right corner of the box you'd like to screenshot and press enter")
    bottom_right = pyautogui.position()
    time.sleep(3)
    width = bottom_right[0] - top_left[0]
    height = bottom_right[1] - top_left[1]
    pyautogui.screenshot(file_name, region=(top_left[0], top_left[1], width, height))


问题


面经


文章

微信
公众号

扫码关注公众号