If you use Apple Script; read this.

As usual Christian comes to the rescue:

https://www.monkeybreadsoftware.net/applescript-nsapplescriptmbs-shared-method.shtml#1

[quote=403936:@Maximilian Tyrtania]As usual Christian comes to the rescue:

https://www.monkeybreadsoftware.net/applescript-nsapplescriptmbs-shared-method.shtml#1[/quote]

That’s only a solution when using an Applescript.

Hello Guys,

About the discussion was not it clear to me if there is a possibility for the user to allow only once and the application does not ask for more?

The user will be asked when your app tries to do something with AppleScript and they haven’t been asked yet. The setting then sticks until they change it via System Preferences.

Hello Tim,

But you know if in case my application fires several different AS and I give permission, they will stay fixed or every time I open the app I will have to give ok ?

It’s once per app, and the setting will stay until the user changes it via System Preferences.

Tanks, Tim !

So if it is asked once per application I think fair, the biggest problem would be every time the application was opened, that would be impossible.

Today a customer reported that my app couldn’t communicate with Photoshop after upgrading to Mojave, the app uses AppleScript.

I believe that the message asking permission appeared at some moment and user denied, message never appeared again and app simply didn’t communicate; the problem is that I haven’t found any way to revoke this except using terminal tccutil reset AppleEvents.
I know permissions can be revoked at System preferences but not denials.

Please kindly let me know if there is a better method, and if NSAppleScriptMBS solves this issue (is it included in last release, Christian?).

Thanks.

This is what I have written for my own app: https://www.mothsoftware.com/blog_page.php?permalink=mail-archiver-and-mojave

This is not an advertisement of my app but meant as illustration for this wonderful AppleScript problem.

You can check if you have permissions with the following code:

[code]'get permissions for new app
dim target as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithBundleIdentifier(BundleID)

// we ask for all apple events
PermissionsForApp = NSAppleScriptMBS.DeterminePermissionToAutomateTarget(target, “", "”, true)
PermissionsDictionary.Value(BundleID) = PermissionsForApp
[/code]

The main problem seems to be that this doesn’t work. The user - if he/she/it can read - expects to see this once. I and other customers get this at least once a day.

And no reaction from Apple on my bug report at all.

Thanks Beatrix.

Not sure but I believe that if a user denies the first time the message appears the connection won’t appear on System Preferences - Privacy and there is no way to revoke the denial except using Terminal, is this correct?

Update: after denying the access the connection appears at System Preferences - Privacy - Automation and you may check it, no need to use Terminal but you have to restart the application.

Tanks for your feedback, Alejandro Fresno Meyer .

[quote=407697:@Alejandro Fresno Meyer]I believe that the message asking permission appeared at some moment and user denied, message never appeared again and app simply didn’t communicate; the problem is that I haven’t found any way to revoke this except using terminal tccutil reset AppleEvents.
I know permissions can be revoked at System preferences but not denials.[/quote]
I’ve created an example that shows how to:

  • determine if the application has permission for AppleEvents / Automation (AEDeterminePermissionToAutomateTarget)
  • In case you determine the application has no permission: How to open System Preferences at Privacy - Automation (so that the user can allow the app)
    This should allow you to check if your app has been denied by the user. And if so, instead of silently failing you can ask him to allow your app by redirecting to the appropriate place in System Preferences.

This is nice. Thank you very much for your example.