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

14

59

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

  • 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

enter image description here

enter image description here

Puncheon answered 12/7, 2018 at 6:55 Comment(0)
P
48

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:

enter image description here

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.

Pectin answered 14/8, 2018 at 17:44 Comment(6)
Thanks, Joe. I can see the problem I have more clearly.Puncheon
Basic testing leads me to believe that the expected functionality of being prompted for permission to allow AppleScript events is working in 10.14 Beta 8 (18A371a). That still doesn't answer the question as to whether or not AppleScript applications can be preauthorized for automation purposes.Pectin
Does not work for me when running through launchd a python script that calls subprocess.run(['/usr/bin/osascript', my_script_path]). I don't get the prompt...Scamp
This helped me with the app center app.rpl(); wasn't working, I follow those steps and check terminal on visual studio.Cordalia
@pxaml I was also able to reproduce the behavior for App Center app.Repl() like you described.Aponte
Thanks for this detailed explanation! The first command in your answer successfully prompted me to grant permissions to Finder via iTerm2. When attempting to do the same with a different app, however, the prompt does not appear. Thus, said app does not appear under Security & Privacy → Privacy → Automation → iTerm. It's infuriation that it's not possible to manually whitelist certain apps, especially when the prompt to grant permissions refuses to show up.Pilot
M
31

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.

enter image description here

Munger answered 19/11, 2018 at 18:22 Comment(4)
None of the settings changes worked for me. Editing the gitk file and removing the offending if block was my solution - the error output says (file "/usr/local/bin/gitk" line 12261) so I simply edited that file. gitk is no longer brought to the front when I launch it but otherwise it works fine.Capelin
I was trying to launch the ios simulator from expo cli, and it failed with the mentioned error message. This fixed it!Goodness
I just ran into this issue after upgrading to Big Sur (11.0). The scripts in question were known good on Catalina (10.15), but suddenly stopped working with the new OS. I'm wondering if old problems (from Mojave, 10.14) might have been re-introduced with the new OS. @Munger fix worked in this case. Thanks Abdullah.Holy
Does anyone know how to "force" an app to appear in this GUI, underneath iTerm 2? Only Finder is showing, and when I try to use osascript in iTerm 2 targeting other apps (other than Finder), I get the error saying permission is not authorized. The problem is that the app does not show up in this GUI, and the authorization popup does not show up, so it appears to be impossible to grant the authorization required. I'm running macOS Monterey 12.1.Pilot
R
18

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 export (File > Export) or save (File > Save As, holding Option key to show Save As) a new 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.

Roughhouse answered 28/9, 2018 at 0:21 Comment(2)
The accepted solution didn't work for me, but this workaround did. Thanks for posting this!Jacobsen
this workaround worked for me, for a legacy application running on Mojave, that requires an AppleScript to start upCarranza
Q
17

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.

Queer answered 22/3, 2019 at 8:2 Comment(3)
This solution won't help Automator (as it should already have this key) -- but if your own application requires apple event access then this new key is required (since 10.14) developer.apple.com/documentation/bundleresources/…Labionasal
Worked like a charm.Wipe
Solved a related problem for me, trying to set this up for my own application. Note that I had to enable it under Accessibility, not Automation as shown in Abdullah's answer (in Ventura 13.4.1)Graphy
L
11

Resetting from Terminal like this fixed it for me:

tccutil reset AppleEvents; tccutil reset SystemPolicyAllFiles

Leclerc answered 11/7, 2019 at 14:55 Comment(2)
Thank you! This is the only thing that fixed the issue for me. I had already granted permission in security/privacy preferences, but was still getting this error. This worked in iTerm, not just for Terminal.Paeon
tccutil: Failed to reset AppleEventsModestia
M
9

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.

Meany answered 4/10, 2018 at 16:54 Comment(2)
This works, but with a little difference: System Preferences > Security & Privacy> Automation > checkmark 'System Events' under the app you want to enable > Enter system passwordTimbering
I will second @AliNem 's comment. I had an Automator workflow that was instructing System Events to make a keystroke in Finder. In System Preferences > Security & Privacy > Accessibility, I had to first enable Automator in Accessibility, then check "System Events" under Finder in Automation, and finally go back and enable Finder in Accessibility. I got a new error each time I tried to run the workflow between each step, until I had made all 3 permissions changes.Cirone
S
5

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

Swope answered 13/7, 2018 at 21:26 Comment(3)
Hmm... I understand that you might have had the same problem like mine because all of my services which made via automator don't work with the alert box. I guess I should wait and see..Puncheon
+1 to this issue. I can run the script inside of the Script editor just fine, but as soon as I make it a quick action or an application and try to launch it fails.Odin
Beta 4 you could 'fix' by copy/pasting to a new script & re-saving. Beta 5 this no longer works & the error is back with a vengeance.Duda
A
3

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.

Astarte answered 16/12, 2019 at 16:42 Comment(0)
A
2

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.

screenshot showing the new Full Disk Access option

Adverb answered 13/6, 2019 at 19:7 Comment(0)
D
2

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.

enter image description here

Drysalter answered 5/10, 2019 at 15:15 Comment(1)
Bingo! Thank you.Michaelson
S
1

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.

Silence answered 18/1, 2019 at 21:23 Comment(1)
Cant believe this is the only thing that worked (deleting-re-adding Automator)Pazpaza
D
1

I received

execution error: Not authorized to send Apple events to Finder. (-1743)" when running a simple smb mount script on Mojave 10.14.6.

Additionally, no apps were able to add security entries to any of the security lists. For example, Microsoft Teams wouldn't display the "wants access to control" dialog boxes for the camera or mic.

This was a standard access user (non-admin). Temporarily elevating this user to an administrator had no impact. No other users were affected. Newly created standard accounts were also unaffected by the problem.

Executing tccutil reset All as the affected user in the Terminal.app displayed a "failed" error.

The fix in this case was to delete the com.apple.TCC folder in the user's Library ~/Library/Application Support/com.apple.TCC and immediately log out.

On login, the folder and contents are rebuilt and normal behaviors are restored.

Dyedinthewool answered 7/12, 2022 at 21:51 Comment(1)
Only this one (rm ~/Library/Application Support/com.apple.TCC and then logout-login) worked for me.Leigha
E
0

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.

Especially answered 15/1, 2019 at 18:1 Comment(0)
C
0

I ran into this problem today using a script I've had for literally a decade that automated rasterizing Illustrator files in Photoshop only to be told it doesn't have permission without a reason to give it. The solutions above don't work because it has nothing to do with System Events in my situation. I then tested and found out I have the same problem in literally every single app on my computer if using osascript. If I tell it in the script to open a file I get a permissions error, but for some absurd reason if I tell it in a script to close an already open file I suddenly get a permissions dialog:

osascript -e "tell application \"Adobe Photoshop 2021\" to close current document saving no"

Thought I'd post it here to help someone else in this exasperating predicament.

Chantellechanter answered 10/12, 2020 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.