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

痞子三分冷 提交于 2019-12-18 10:48:13

问题


After I updated to Mojave, I can no longer use the automator service I've previously been using with the alert below.

  • In Security & Privacy, I already checked AppleScript Editor.

Do you see any problem with my code or is this the problem of the newest macOS?

Script

on run {input, parameters}
set pathList to {}
repeat with itemNum from 1 to count of input
    tell application "System Events"
        copy POSIX path of (container of (item itemNum of input)) to end of pathList
    end tell
end repeat
return pathList
end run


回答1:


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:

  • https://www.felix-schwarz.org/blog/2018/06/apple-event-sandboxing-in-macos-mojave
  • https://forums.developer.apple.com/thread/106949

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




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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




回答7:


Resetting from Terminal like this fixed it for me:

tccutil reset AppleEvents; tccutil reset SystemPolicyAllFiles




回答8:


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.




回答9:


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.




回答10:


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.




回答11:


if you don't get something like this when trying to run your apple script, and more over you don't see iTerm in your Automation section in Privacy Setting, then the simplest possible way may help: JUST RESTART your Mac ;) disclaimer: another reason for that situation on my side may be user switching.




回答12:


I had this error in Terminal.app on Catalina with the simple test script of osascript -e 'tell application "Finder" to display notification "some stuff".

I was not getting the pop-up and did not find any helpful options in Settings -> Security & Privacy -> Privacy -> Automation -> Privacy (neither Automation, nor Full Disk Access). I also did not have any luck with tccutil reset AppleEvents; tccutil reset SystemPolicyAllFiles (other than unfortunately losing all my relevant preferences).

For me, the issue was that I was running the command in tmux. Once I detached from tmux, running the same command in Terminal prompted me for the relevant permissions dialog. Once allowed and reattached to my tmux session, I still could not run the command in tmux (but ran in Terminal outside of tmux). At this point I killed my tmux session, launched a new session, and thereafter was able to run this command in tmux in Terminal.



来源:https://stackoverflow.com/questions/51299066/macos-mojave-automator-not-authorized-to-send-apple-events-to-system-events

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