The problem
In a script I'm using AppleScript to reload the browser when a change happens. I start this in the builtin terminal of my IDE, WebStorm.
Since MacOS Catalina this yields the following error:
English
execution error: System Events got an error: osascript is not allowed to send keystrokes. (1002)
German/Deutsch
execution error: „System Events“ hat einen Fehler erhalten: osascript ist nicht berechtigt, Tastatureingaben zu senden. (1002)
The solution
I added /usr/bin/osascript
and WebStorm.app via 'Choose File' dialog to System Preferences > Security & Privacy > Privacy > Accessibility
(German/Deutsch: Systemeinstellungen > Sicherheit > Datenschtuz > Bedienungshilfen
).
But since Catalina/Mojave it must also appear under the new section Automation. Only there is no 'Choose File' dialog and when running the script no confirmation dialog pops up so (un)checkable entry is created.
How can I allow System Events under System Preferences > Security & Privacy > Privacy > Automation
?
Best Answer
osascript -e 'tell application "System Events"' -e 'keystroke "echo hi"' -e end tell
will add an entry System Events under ther terminal emulator where you run it from in the automation section./System/Library/CoreServices/System Events.app
to Accessibility/Bedienungshilfen via 'Choose File' dialogPossibly lock and unlock between rechecking/readding or run multiple times or prefixed by
sleep 1 &&
. These new security settings unfortunately still seem a bit messy (good links for further reading there!):Nope :-(
By the way,
osascript -e 'tell application "System Events"' -e "keystroke key code 53" -e end tell
ran twice will add the entry for the program itself under the program.