Open samshum opened 2 years ago
Same issue with python 3.10.6 on Monterey and looks like returned coordinates are doubled somehow. Try dividing by 2. It worked for me. Did not ditched the code to fix it though but appreciate if someone can do it for the next release.
OS: MACOS Monterey12.6 Python version: Python 3.8's Code:
def testClickEvent(): btpoing = pyautogui.locateOnScreen('bt.png') x, y = pyautogui.center(btpoing) #pyautogui.click(x, y) print(x, y) print('-----------------------------') while(True): print(pyautogui.position()) time.sleep(1)
Result value: 4480 1712 Accurate value: Point(x=2267, y=855)
4480 1712
Point(x=1420, y=325) Point(x=1420, y=325) Point(x=1420, y=325) Point(x=1292, y=234) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855)
I think it's a known issue. You most likely have a retina screen, which increases resolution (2x) of the amount of pixels which are on the screen. As @lemontreefour said, the easiest way to avoid this issue, is by dividing your returned position by 2.
OS: MACOS Monterey12.6 Python version: Python 3.8's Code:
def testClickEvent(): btpoing = pyautogui.locateOnScreen('bt.png') x, y = pyautogui.center(btpoing)
pyautogui.click(x, y)
Result value: 4480 1712 Accurate value: Point(x=2267, y=855)
4480 1712
Point(x=1420, y=325) Point(x=1420, y=325) Point(x=1420, y=325) Point(x=1292, y=234) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855) Point(x=2267, y=855)