10

I have two MacBooks. Both run the same MacOS version. I installed the same Automator script in both. But on the older MacBook I get:

The action “Run AppleScript” encountered an error: “System Events got an error: com.automator.runner.xpc is not allowed to send keystrokes.”

I added Automator to the Security -> Accessibility section in both. It even works on the older one. But then it suddenly stops. It just don't get why...

5
  • What version of macOS? Jun 19, 2020 at 13:39
  • Most recent one.
    – steros
    Jun 19, 2020 at 13:57
  • Does System Events have Accessibility privileges? Jun 19, 2020 at 16:48
  • yeah it has these privileges.
    – steros
    Jun 21, 2020 at 10:18
  • You should paste the script so we can test it out. I usually change the syntax or isolate the problem to see if it works alone. Often it is just a matter of tweaking the "delay" between commands. Older computers need more time to get ready for the next step. Oct 15, 2020 at 4:32

3 Answers 3

18

I have solved this issue recently in case anyone is interested in how. It is NOT actually necessary for System Events to have direct Accessibility privileges. What you need to add are a total of 3 apps, Automator, Script Editor, and AppleScript Utility.

The Automator and Script Editor apps are found within the ~/Applications and ~/Applications/Utilities folders, respectively. What is harder to find is the AppleScript Utility app, seen below:

enter image description here

To add AppleScript Utility app, click the + button on Accessibility, then navigate to (a shortcut is CMD+SHIFT+G)

/System/Library/CoreServices

then open the application called AppleScript Utility.

Afterwards, run a script in automator again, which updates the privileges and things should run well after. In summary, Automator, Script Editor, and AppleScript Utility need to be added to Accessibility.

3
  • 4
    Unfortunately doesn't work for me. Actually I found out whatever I add to accessibility makes it work. But only to restart at max. Then it just stops working again. Usually does after a few minutes.
    – steros
    Sep 15, 2020 at 3:32
  • Ugh I'm having the same problem. When I first followed these instructions, it worked, but restarting broke it again.
    – jerclarke
    May 26, 2022 at 21:07
  • Ok, I found another solution! SCRIPTS CANNOT HAVE SPACES IN THEIR NAMES! Replaces spaces with dashes/underscores fixed my situation, along with following all the advice above: stackoverflow.com/a/59036828/209859
    – jerclarke
    May 26, 2022 at 21:30
11

I found that all applications involved that are targeted by the Automation also need to be given Accessibility permission. So, if your Automation reloads a page in Chrome then both Chrome and Automator require Accessibility permissions.

4
  • Thanks! This worked for me. I use a workflow to pass search queries to different websites in Safari (see: apple.stackexchange.com/a/371138/214359). Giving Accessibility access to Safari did the trick.
    – Luke Davis
    Dec 17, 2020 at 20:24
  • Unfortunately also does not work for me.
    – steros
    Feb 5, 2021 at 7:34
  • 2
    After doing adding Automator, Script Editor, and AppleScript Utility to Accessibility as user321627 noted, it worked fine...for a few minutes. Later in the day, it did not work. How quirky? As you suggested and add the target application to have accessibility permissions and then my automation worked. Grr, apple! Feb 12, 2021 at 19:05
  • I have found the same - that the target application needs to be given Accessibility permission. However I found that Automator actually doesn't need Accessibility permission if the target application has it. I end up temporarily granting permission to the target application while I'm invoking the Automator script and then revoking it.
    – mark
    Mar 14, 2021 at 21:15
1

Another thing that COULD be causing problems is spaces in the script name. I have no idea why, but as this comment on another question pointed out, it seems that having spaces in the filename of the script can cause these errors to persist even if you've added everything possible to the Acessibility app whitelist!

So remove all spaces from your script filename and replace with - or _!

Then go back through the many useful answers in this thread and make sure you've whitelisted all the apps needed.

Worked for me, hopefully this helps some others who are trapped in error-hell!

1
  • I don't think that is the problem but it is a good policy just to do this to avoid errors in general. Jul 24, 2023 at 21:38

You must log in to answer this question.

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