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
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.
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...
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.
来源:https://stackoverflow.com/questions/51299066/macos-mojave-automator-not-authorized-to-send-apple-events-to-system-events