Pyautogui not running on Mac? (Catalina)

Viewed 3872

I'm trying to run the following from terminal on my mac, but what's happening is the code appears to run (I don't get any error message), python (as an app) on my mac bounces on my dock as if to open and then it doesn't do anything and then it stops running. I can't tell if this is a permissions issue or a Mac Catalina issue or an issue with my code!

import pyautogui as gui
count= 0
gui.click(1080,521)
while count<5:
    gui.FAILSAFE=True
    gui.write(f'This is a test {count}x')
    count += 1
    gui.press('enter')

I've already tried to run the sudo command, I've also tried:

gui.moveTo(1080,521)
gui.dragTo(button='left')

in place of the gui.click command, but nothing seems to be working! Help?

2 Answers

Turns out this was a permissions issue - in Mac System Preferences I needed to give access to Terminal to control my mouse

In my case with Big Sir System Env I did

setting -> security & privacy -> Accessibility -> Terminal 'check'

It works well now.

Related