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

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

项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
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)
项目: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
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
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
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def get_pos():
    cur_x, cur_y = pg.position()
    print cur_x, cur_y
项目: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()
项目: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)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_r(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("r", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_t(self):
        x = pyautogui.position()
        pyautogui.click(x)
        pyautogui.press("t", interval=0.1)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def presskey_u(self):
        x = pyauotgui.position()
        pyautogui.click(x)
        pyautogui("u", interval=0.1)
项目:autoclicker    作者:nkoeppel    | 项目源码 | 文件源码
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
项目:osrmacro    作者:jjvilm    | 项目源码 | 文件源码
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)
项目:osrmacro    作者:jjvilm    | 项目源码 | 文件源码
def mouse_loc():
    return pyautogui.position()
项目:PyKinectTk    作者:Qirky    | 项目源码 | 文件源码
def fromPosition():
        raw_input("Hover over the location you want to click and press enter")
        return position()
项目:PyKinectTk    作者:Qirky    | 项目源码 | 文件源码
def run(self):
        while self.running:
            self.click()
            sleep(self.time_step)
            if (self.x, self.y) != position():
                self.running=False
项目:PYSHA    作者:shafaypro    | 项目源码 | 文件源码
def get_positions(self):
        x, y = pyautogui.position()  # this returns a tupple as in the x and the y
        return x, y
项目:RunescapeBots    作者:lukegarbutt    | 项目源码 | 文件源码
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))