asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

bug: pyautogui.moveTo() doesn't work on macOS Sonoma #834

Open wkoszek opened 8 months ago

wkoszek commented 8 months ago

I can't get the moveTo() to work on Sonoma. Snippet:

>>> pyautogui.position()
Point(x=521, y=639)
>>> pyautogui.position()
Point(x=233, y=862)
>>> pyautogui.moveTo(100, 150)
>>> pyautogui.position()
Point(x=233, y=862)
>>> pyautogui.moveTo(1, 1)
>>> pyautogui.position()
Point(x=233, y=862)
>>> pyautogui.moveTo(1000, 10000)
>>> pyautogui.moveTo(1000, 1000)
>>> pyautogui.position()
Point(x=233, y=862)

So without doing anything it appears cursor is not moved. The cursor of the screen also does't change.

Example from Ubuntu + dwm:

image

here it works OK.

HerbCSO commented 8 months ago

I believe you need to give your python process permissions to control your computer. Specifically I think the Accessibility permission under System Settings -> Privacy & Security.

Depending on how you're running your code, you may need to give the permissions to the correct Python executable (careful of which path you're using) or something like Visual Studio Code if you're running it from there.

getvictor commented 3 months ago

We need better debug messages or instructions here. I can't enable Accessibility permissions on python -- all the files are greyed out.

image