2

I am using an AppleScript app (i.e., an AppleScript exported to an OS X app) to copy the message ID of an e-mail currently selected in Mail.app to the clipboard.

Whenever I run the AppleScript app, I have to confirm that it is allowed to read the message ID from Mail.app. That is, I get a popup asking:

“Get-E-Mail-Message-ID.app“ wants access to control “Mail.app“. Allowing control will provide access to documents and data in “Mail.app“, and to perform actions within that app. This script needs to control other applications to run.

With two buttons, [Don't Allow] and [OK]. So I always have to click [OK].

Is it possible to permanently grant my app to read data from Mail.app?

I have already found System Preferences -> Security & Privacy -> Privacy, and checked the box under "Allow the apps below to control other apps.", but still get the popup whenever I run the AppleScript app.

2 Answers 2

3

A regular AppleScript saves properties and global variables (including variables in either run handler) in the script itself (the script file is modified). This is how persistent properties have been implemented, but now this can run into accessibility permissions issues, since modifying an application will cause the system to see it as a different one - one that hasn't been given permission.

The solution is to code sign your application (you can use a self-issued certificate) or make the scripts in the bundle run-only. You will lose persistent properties, but you can use some AppleScriptObjC to implement preferences via NSUserDefaults if you need to keep stuff between runs.

2

Select the file in Finder and Get Info, then make sure it's Locked.

Note: This "works" because it stops the script from modifying itself, however note that this may stop the script from working correctly. See the other answer on this post.

3
  • 1
    Welcome to Ask Different! We're trying to find the best answers and those answers will be more than just one line. Providing supporting info and links can also help the OP, and others, find additional info for themselves. See How to Answer on how to provide a quality answer. - From Review
    – fsb
    Commented Dec 4, 2020 at 21:06
  • Holy CRAP this did indeed solve the issue for me in Mojave. I am STUNNED!!!!
    – JVC
    Commented Jan 17, 2021 at 19:22
  • One point to add, it solved the problem for me assuming I had already allowed access at least once already.
    – JVC
    Commented Jan 17, 2021 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .