pyautogui: Pyautogui doesn't seem to work on macOS Mojave
I recently updated to macOS Mojave (10.14 Beta). Commands like pyautogui.moveTo(1027,73)
, pyautogui.click(1027,73)
, etc. don’t seem to work at all. Neither any error messages are thrown nor do the method calls work. pyautogui worked perfectly on macOS High Sierra.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 24
- Comments: 20
Not a pyautogui user, but on Mojave, there’s a new security feature where you must explicitly allow applications to use your mouse/keyboard. Have a look in Security Preferences > Security & Privacy > Privacy > Accessibility - you might have to allow your terminal application in the list.
@DimitriosLisenko You are right! This actually worked, personally I’m using iTerm so I had to add it in Accessibility as you described!
This works fine for me. You have to install another library pynput
from pynput.mouse import Listener, Controller, Button
mouse = Controller()
pyautogui.moveTo(x, y) mouse.click(Button.left, 2)
In MAC with Ventura and Visual Studio Code just Preferences > Security & Privacy > Privacy > Accessibility and allow Visual Studio Code to control your computer, it worked great for me