当前位置: 首页>>代码示例>>Python>>正文


Python pyautogui.position函数代码示例

本文整理汇总了Python中pyautogui.position函数的典型用法代码示例。如果您正苦于以下问题:Python position函数的具体用法?Python position怎么用?Python position使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了position函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_moveRel

    def test_moveRel(self):
        # start at the center
        desired = self.center
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down and right
        desired += P(42, 42)
        pyautogui.moveRel(42, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up and left
        desired -= P(42, 42)
        pyautogui.moveRel(-42, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move right
        desired += P(42, 0)
        pyautogui.moveRel(42, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down
        desired += P(0, 42)
        pyautogui.moveRel(None, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move left
        desired += P(-42, 0)
        pyautogui.moveRel(-42, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up
        desired += P(0, -42)
        pyautogui.moveRel(None, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel([42, 42])
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveRel((-42, -42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel(P(42, 42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)
开发者ID:csampaio,项目名称:screen2text,代码行数:60,代码来源:autoguitest.py

示例2: main

def main():

	while True:
        	position = pyautogui.position()
		time.sleep(60)
		if position == pyautogui.position():
			pyautogui.moveRel(0,-1)
			pyautogui.moveRel(0,1)
开发者ID:dallanwagz,项目名称:py-hax,代码行数:8,代码来源:movemouse.py

示例3: Start

def Start(pos):
    pyautogui.FAILSAFE = False
    global root, running
    im=pyautogui.screenshot()
    pos['text']=str(pyautogui.position())
    rgb['text']=str(im.getpixel(pyautogui.position()))
    root.update_idletasks()
    root.after(10, lambda:Start(pos))
开发者ID:tushutripathi,项目名称:posRGB,代码行数:8,代码来源:posRGB.py

示例4: func

        def func():
            self.screenshot_button.config(state='disabled')

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Deselect the game window %s' % second)
                if second != 0:
                    time.sleep(1)

            region = []
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the top left\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_top_left = pyautogui.position()
            region.extend(constant_top_left)
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the bottom right\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_bottom_right = pyautogui.position()
            region.extend(
                (constant_bottom_right[0] - constant_top_left[0],
                 constant_bottom_right[1] - constant_top_left[1])
            )
            self.deselected_screenshot = pyautogui.screenshot(region=region)
            pyautogui.click()
            self.selected_screenshot = pyautogui.screenshot(region=region)

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the top left\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            top_left = pyautogui.position()
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the bottom right\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            bottom_right = pyautogui.position()

            self.screen_size = [
                constant_top_left[0] - top_left[0],
                constant_top_left[1] - top_left[1],
                bottom_right[0] - constant_bottom_right[0],
                bottom_right[1] - constant_bottom_right[1]
            ]

            self.screenshot_taken = True
            self.screenshot_label.config(text='Screenshot Taken')
            self.screenshot_button.config(
                state='normal', text='Retake Screenshot')
开发者ID:jaronoff97,项目名称:play_as_one,代码行数:55,代码来源:PlayAsOne.py

示例5: v_scroll_on_android

def v_scroll_on_android(scroll_value=20, locate_first_on_center = True, scrollDown = True):
    # Locate the mouse on screen center
    if(locate_first_on_center is True):
        locate_on_center()
    # Simulate drag and drop
    # pyautogui.mouseDown();
    x, y = pyautogui.position()[0], pyautogui.position()[1]
    if(scrollDown is True):
        y = y - scroll_value;
    else:
        y = y + scroll_value;
    pyautogui.dragTo(x, y)
开发者ID:g-sari,项目名称:py-mario-ai,代码行数:12,代码来源:utils.py

示例6: showLocation

	def showLocation():
		lastLoc = (0,0)
		newLoc = (1,0)
		while lastLoc !=  newLoc:
			x, y = pyautogui.position()
			time.sleep(0.25)
			locX.delete(0,END)
			locY.delete(0,END)
			locX.insert(0,x)
			locY.insert(0,y)
			lastLoc = newLoc
			newLoc = pyautogui.position()
开发者ID:Box-Of-Hats,项目名称:Py-Macro,代码行数:12,代码来源:MacroRecorderApplication.py

示例7: onClick

	def onClick(self, mouse_button):
		if mouse_button == 4: #scroll up
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(1)
			pyautogui.moveTo(*prev, pause=False)
		elif mouse_button == 5: #scroll dn
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(-1)
			pyautogui.moveTo(*prev, pause=False)
		else: #do nothing
			pass
开发者ID:MCManuelLP,项目名称:dotfiles,代码行数:13,代码来源:status_base.py

示例8: test_position

    def test_position(self):
        mousex, mousey = pyautogui.position()

        self.assertTrue(isinstance(mousex, int), 'Type of mousex is %s' % (type(mousex)))
        self.assertTrue(isinstance(mousey, int), 'Type of mousey is %s' % (type(mousey)))

        # Test passing x and y arguments to position().
        pyautogui.moveTo(mousex + 1, mousey + 1)
        x, y = pyautogui.position(mousex, None)
        self.assertEqual(x, mousex)
        self.assertNotEqual(y, mousey)

        x, y = pyautogui.position(None, mousey)
        self.assertNotEqual(x, mousex)
        self.assertEqual(y, mousey)
开发者ID:asweigart,项目名称:pyautogui,代码行数:15,代码来源:test_pyautogui.py

示例9: auto_mouse

def auto_mouse():
	auto.moveTo(450,450)
	pos = auto.position()

	auto.moveRel(-200,-200)
	pos2  = auto.position()
	for i in range(100 ):
		try:
			auto.moveTo(pos, duration = 1, tween = auto.easeInCubic)
			auto.click()
			auto.moveTo(pos, duration = 1)
			auto.click()
			auto.moveTo(pos2,duration = 1, tween = auto.easeInQuad)
		except:
			sys.exit()
开发者ID:arhik,项目名称:NuLocale,代码行数:15,代码来源:mouse_automation.py

示例10: test_moveTo

    def test_moveTo(self):
        # moving the mouse
        desired = self.center
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # no coordinate specified (should be a NO-OP)
        pyautogui.moveTo(None, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse to a new location
        desired += P(42, 42)
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse over time (1/5 second)
        desired -= P(42, 42)
        pyautogui.moveTo(desired.x, desired.y, duration=0.2)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse with only x specified
        desired -= P(42, 0)
        pyautogui.moveTo(desired.x, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # ...and only y specified
        desired -= P(0, 42)
        pyautogui.moveTo(None, desired.y)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveTo(list(desired))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveTo(tuple(desired))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveTo(desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)
开发者ID:csampaio,项目名称:screen2text,代码行数:53,代码来源:autoguitest.py

示例11: clickAndReturnMouseCoords

def clickAndReturnMouseCoords(coords):
    orig_x,orig_y = pyautogui.position()
    pyautogui.moveTo(coords[0],coords[1])
    pyautogui.click()
    logging.info('CLICK')
    pyautogui.moveTo(orig_x, orig_y)
    return
开发者ID:starcraft04,项目名称:swauto,代码行数:7,代码来源:functions_opencv.py

示例12: initialize

def initialize():
    if not os.getenv('GOOGLE_API_KEY'):
        print('*' * 80)
        print('You must set GOOGLE_API_KEY to OS environments.')
        print('Please check https://developers.google.com/maps/documentation/javascript/get-api-key')
        print("export GOOGLE_API_KEY='blahblah' to ~/.bash_profile")
        print('*' * 80)
        raise NameError('GOOGLE_API_KEY')

    print("Cursor on GPS button of xcode.")
    input("press enter to continue")
    gps_button_pos = pyautogui.position()
    print("Cursor on GPX file of xcode. (pikapika.gpx)")
    input("press enter to continue")
    gpx_file_pos = pyautogui.position()
    return gps_button_pos, gpx_file_pos
开发者ID:Ipukema,项目名称:PokemonGoWithMap,代码行数:16,代码来源:runserver.py

示例13: clickAndReturnMouse_point

def clickAndReturnMouse_point(point):
    orig_x,orig_y = pyautogui.position()
    pyautogui.moveTo(point['center'][0],point['center'][1])
    pyautogui.click()
    logging.info('CLICK')
    pyautogui.moveTo(orig_x, orig_y)
    return
开发者ID:starcraft04,项目名称:swauto,代码行数:7,代码来源:functions_opencv.py

示例14: __init__

 def __init__(self,mag=100, browser='Firefox'):
     top_bar = {'Firefox':100,'Chrome':115}
     self.__x, self.__y = position()
     self.__top_bar = top_bar[browser]
     self.__y -= top_bar[browser]
     self.__center = False
     self.__mag = mag
开发者ID:xenialenvy,项目名称:Agarbot,代码行数:7,代码来源:Blob.py

示例15: test

def test():
    i = 0
    while i < 5:
        i = i + 1
        print pyautogui.position()
        #window = pyautogui.locateCenterOnScreen('wood.png')
        windows = pyautogui.locateAllOnScreen('key.png')
        #if window is None:
        #    sys.exit('Could not find game on screen. Is the game visible?')
        for window in windows:
            l = window[0]
            t = window[1]
            w = window[2]
            h = window[3]
            time.sleep(0.1)
            pyautogui.moveTo(l+w/2, t+h/2)
开发者ID:Baart,项目名称:py,代码行数:16,代码来源:autobot.py


注:本文中的pyautogui.position函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。