macOS Mojave, Automator “Not authorized to send Apple events to System Events.”

邮差的信 提交于 2019-11-30 01:26:01

This is definitely a part of Mojave's new security framework. In terminal try

osascript -e 'tell application "Finder"' -e 'set _b to bounds of window of desktop' -e 'end tell'

and you may receive:

36:42: execution error: Not authorized to send Apple events to Finder. (-1743)

What is supposed to happen on the first execution is the Finder opens a dialog box informing you that terminal is requesting permission to send events to the Finder. If you allow it, then terminal will get added to the Automation page in System Preferences > Security & Privacy > Automation:

There's two issues that I see at the moment:

  • the implementation of requesting permission for the scripting action appears to be bugged; I've run other scripts that request permission to send events to Safari and the Finder doesn't prompt for permission, it just returns an error.
  • streamlined automation requires some type of mechanism to have the permissions granted a priori; an example would be utilizing AppleScript with Ansible and being unable to preload grants

Others have written up more extensive information about this:

Hopefully this gets worked out before Mojave ships as it seriously impacts automation capabilities on macOS.

I faced same error opening gitk.

Error in startup script: execution error: Not authorised to send Apple events to System Events. (-1743)


SOLUTION

Goto Settings -> Security & Privacy -> Privacy -> Automation -> Privacy tab and check the System Events checkbox.

I had a similar error running AppleScript .app applications. I received the following error:

Not authorized to send Apple events to Finder. (-1743)

A workaround is to re-export the Application from the .scpt or .applescript source code. This generates a new .app application, which in my case ran successfully. The initial launch required approval (as well as some subsequent launches), and the application was added as an entry under Settings -> Security & Privacy -> Privacy -> Automation.

Here is what I did that resolved the issue for me. I went to System Preferences > Security & Privacy > Accessibility (Options on left hand side) > (Enter system password) > Click Automator (or your app you want to enable) and TADA it works.

I have solved the same issue using the below steps. Open Plist and add the below keys in it

<key>NSAppleEventsUsageDescription</key>
<string>Please give access to Export details to Outlook</string>

You will get a confirmation pop up to allow or disallow when your application starts executes the script first time. if you click allow, it will execute the script.

UPDATE: Updating to the latest Public Beta (as of 4 August 2018) fixed the issue for me. Prior to this, the issue did persist in all public betas of Mojave.


Original reply:

Just wanted to let you know that both myself and another friend are experiencing this exact same problem, with different Automator workflows that use Applescript (different than yours). We have the problem occurring with both manual activation (Finder --> Services --> click item) and with keyboard shortcut activation.

Even stranger, the workflow performs beautifully when testing inside Automator.

I've filed a bug report through the Feedback Assistant, and suggest to anyone else who sees this that you do too! Squeaky wheel and all...

Automator - Permissions error. "The action “Run AppleScript” encountered an error: “Not authorized to send Apple events to System Events.”"

Automator workflow performing well inside Automator

Resetting from Terminal like this fixed it for me:

tccutil reset AppleEvents; tccutil reset SystemPolicyAllFiles

I was trying to insert the current date into the Reminders app with a keystroke. Instead of using the recommended "Settings -> Security & Privacy -> Privacy -> Accessibility -> Automator", I had to add Reminders instead of Automator so that it would allow the keystroke command to be permitted. It is annoying that it only permits the action on the specific app but that seems to be the case.

I was still having issues sending keystrokes a few months after Mojave was released. For me, weirdly the fix was to go System Preferences -> Security and Privacy -> Privacy Tab -> Unlock the Lock with your password -> Remove (with the minus button) Automator from the list of Apps in the Accessibility Row. Maybe there was something from running the betas that needed to get deleted before my scripts could send keystrokes again.

Edit: After quitting System Preferences I was getting the alert error again. Re-adding Automator.app to the Accessibility row seems to have fixed this for now.

In my case I had to go:

Settings & Privacy > Privacy > Full Disk Access (in the left hand panel) and add Automator

I had also tried adding Automator to Accessibility as other answers suggested (which didn't initially work for me) so perhaps we need to add Automator in both places.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!