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


Python pyautogui.position方法代码示例

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


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

示例1: test_moveToWithTween

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def test_moveToWithTween(self):
        origin = self.center - P(100, 100)
        destination = self.center + P(100, 100)

        def resetMouse():
            pyautogui.moveTo(*origin)
            mousepos = P(*pyautogui.position())
            self.assertEqual(mousepos, origin)

        for tweenName in self.TWEENS:
            tweenFunc = getattr(pyautogui, tweenName)
            resetMouse()
            pyautogui.moveTo(destination.x, destination.y, duration=pyautogui.MINIMUM_DURATION * 2, tween=tweenFunc)
            mousepos = P(*pyautogui.position())
            self.assertEqual(
                mousepos,
                destination,
                "%s tween move failed. mousepos set to %s instead of %s" % (tweenName, mousepos, destination),
            ) 
开发者ID:asweigart,项目名称:pyautogui,代码行数:21,代码来源:test_pyautogui.py

示例2: test_moveRelWithTween

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def test_moveRelWithTween(self):
        origin = self.center - P(100, 100)
        delta = P(200, 200)
        destination = origin + delta

        def resetMouse():
            pyautogui.moveTo(*origin)
            mousepos = P(*pyautogui.position())
            self.assertEqual(mousepos, origin)

        for tweenName in self.TWEENS:
            tweenFunc = getattr(pyautogui, tweenName)
            resetMouse()
            pyautogui.moveRel(delta.x, delta.y, duration=pyautogui.MINIMUM_DURATION * 2, tween=tweenFunc)
            mousepos = P(*pyautogui.position())
            self.assertEqual(
                mousepos,
                destination,
                "%s tween move failed. mousepos set to %s instead of %s" % (tweenName, mousepos, destination),
            ) 
开发者ID:asweigart,项目名称:pyautogui,代码行数:22,代码来源:test_pyautogui.py

示例3: adjust_click_position

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def adjust_click_position(click_x, click_y, window_width, window_height, dest_x, dest_y, dest_width, dest_height):
	# get screen size
	screen_width, screen_height = pyautogui.size()
	if screen_width > window_width and screen_height > window_height:
		# fit position to destination size
		new_x, new_y = fit_position_to_destination(click_x, click_y, window_width, window_height, dest_width, dest_height)
		#print('new_x: %d, new_y: %d, dest_x: %d, dest_y: %d' % (new_x, new_y, dest_x, dest_y))
		# scale to screen
		x = new_x + dest_x
		y = new_y + dest_y
	else:
		x = click_x
		y = click_y
	return (x, y)

# Perform a simple click or double click on x, y position 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:18,代码来源:tools.py

示例4: fromPosition

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def fromPosition():
        raw_input("Hover over the location you want to click and press enter")
        return position() 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:5,代码来源:AutoClick.py

示例5: run

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def run(self):
        while self.running:
            self.click()
            sleep(self.time_step)
            if (self.x, self.y) != position():
                self.running=False 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:8,代码来源:AutoClick.py

示例6: test_position

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
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,代码行数:17,代码来源:test_pyautogui.py

示例7: test_moveTo

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
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)

        # 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:asweigart,项目名称:pyautogui,代码行数:43,代码来源:test_pyautogui.py

示例8: repeat_click

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def repeat_click(cls,say, adjust_x=0, adjust_y=0, interval=0.10):
        rect =cls.find_window_movetop()
        posx = rect[0]
        posy = rect[1]

        x, y = pyautogui.position()
        x = x+adjust_x
        y = y+adjust_y
        print(x, y)
        pyautogui.click(m.ceil(x+posx), m.ceil(y+posy), clicks=say-1, interval=interval) 
开发者ID:Sunuba,项目名称:roc,代码行数:12,代码来源:Clicker.py

示例9: mouse_pos

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def mouse_pos(cls):
        rect =cls.find_window_movetop()
        posx = rect[0]
        poxy = rect[1]
        x, y = pyautogui.position()
        m_p = [x, y]
        return m_p 
开发者ID:Sunuba,项目名称:roc,代码行数:9,代码来源:Clicker.py

示例10: position

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def position():
        print(pyautogui.position()) 
开发者ID:Sunuba,项目名称:roc,代码行数:4,代码来源:Commands.py

示例11: get_widget_location

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def get_widget_location(widget):
	if widget:
		# get widget allocation (relative to parent)
		allocation = widget.get_allocation()
		# get widget position (relative to root window)
		if type(widget) in (Gtk.DrawingArea, Gtk.EventBox, Gtk.Socket):
			pos = widget.get_window().get_origin()
			return (pos.x, pos.y, allocation.width, allocation.height)
		else:
			pos_x, pos_y = widget.get_window().get_root_coords(allocation.x, allocation.y)
			return (pos_x, pos_y, allocation.width, allocation.height)
	else:
		return None

# Check if position is inside given bounds 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:17,代码来源:tools.py

示例12: position_is_inside_bounds

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def position_is_inside_bounds(pos_x, pos_y, bounds_x, bounds_y, bounds_width, bounds_height):
	if pos_x > bounds_x and pos_x < (bounds_x + bounds_width) and pos_y > bounds_y and pos_y < (bounds_y + bounds_height):
		return True
	else:
		return False

# Fit position coordinates to given destination 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:9,代码来源:tools.py

示例13: perform_click

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def perform_click(x, y, double=False):
	old_position = pyautogui.position()
	if double:
		pyautogui.doubleClick(x=x, y=y, interval=0.1)
	else:
		pyautogui.click(x=x, y=y)
	pyautogui.moveTo(old_position)

# Press key 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:11,代码来源:tools.py

示例14: get_mouse_position

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def get_mouse_position():
	return pyautogui.position()

# Return screen size 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:6,代码来源:tools.py

示例15: test_simple

# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import position [as 别名]
def test_simple(self):
        width, height = pyautogui.size()
        toPoint = (width//2, height//2)
        hc = HumanClicker()
        hc.move(toPoint)
        self.assertTrue(pyautogui.position() == toPoint) 
开发者ID:patrikoss,项目名称:pyclick,代码行数:8,代码来源:test_humanclicker.py


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