當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。