Skip to content

[Solved][AppleScript] error “System Events got an error: Script Editor is not allowed to send keystrokes.” number 1002

Today when I trying to use AppleScript to write a script on Mac OS for automatically keying in some text. But I got an error message as follow:

error "System Events got an error: Script Editor is not allowed to send keystrokes." number 1002

Solution

This is a security protection mechanism of Mac OS, in order to avoid unauthorized commands to operate System Events. The fastest way to solve this problem is to give me access to the Script Editor software I use.

Open the setting window in the following order: Apple icon in the upper left corner > System Preferences… > Security & Privacy > Accessibility.

Unlock first and then add
Add Script Editor

Then you should be able to successfully execute the script.


Reference


Read More

2 thoughts on “[Solved][AppleScript] error “System Events got an error: Script Editor is not allowed to send keystrokes.” number 1002”

  1. This doesn’t resolve the problem. I have a script in ~/Library/Scripts/Applications/Name_of_the_application/ (so the script is accessible in the menu bar in the script menu, when I’m in the app Name_of_the_application). The script worked one year ago. Yet (macOS Monterey 12.5.1) it doesn’t work : error 1002 (yes, in the script I have : keystroke “x” using command down). Any hint welcome. Better : cannot Apple made a public statement to help AppleScript users with all their security updates ? In Security and Privacy> … > Accessibility, I have checked AEServer, Script Editor, Name_of_the_app, Script Menu.app (the path is: /System/Library/CoreServices/Script Menu.app).

  2. I have the same problem in Monterey. I have a simple 1-line applescript
    tell application “System Events” to keystroke “n” using {command down, shift down}
    and I have added both script editor and this app to both Full Disk Access and Accessibility in the Security & Privacy pref pane. The app is named “New” so there are no spaces in its name (a problem mentioned in another thread).

Leave a Reply