0

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?

0

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.

  • If you receive execution error 1002 again, uncheck and recheck System Events under Automation again.
  • If you receive execution error -1743: Remove the app from the Accessibility/Bedienungshilfen section and add it again
    • execution error: Not authorized to send Apple Events to System Events. (error -1743)
    • execution error: Keine Berechtigung zum Senden von Apple-Events an System Events. (-1743)
  • If you receive execution error -1719: Add /System/Library/CoreServices/System Events.app to Accessibility/Bedienungshilfen via 'Choose File' dialog
    • execution error: System Events got an error: osascript is not allowed assistive access. (-1719)

Possibly 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!):

Hopefully this gets worked out before Mojave ships.

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.

Screenshot from MacOS System Settings showing the relevant options

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .