I'm using Keyboard Maestro 9.0.3 on Mojave (10.14.6, latest before Catalina). Recently, I am being prompted to enter my password whenever I want to execute a macro involving AppleScript. The message goes like so:
Osascript is trying to send restricted scripting addition commands to other applications. Enter your password to allow this.
This started recently and I cannot connect it to some event, e.g. the installation of some new application or what have you. I've tried the traditional routes like toggling permissions in Accessibility on and off, repairing permissions, to no avail.
What do you suggest I try next to solve this issue? It's quite irritating and often defeats the purpose of using macros for a good portion of everyday tasks.
P.S. Thinking further on the events preceding the problem has me wondering if (re)connecting my NAS has something to do with it, but it never caused these issues in the past.
I tried now and that's the only way it will execute the script
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell current application
set mvfiles to selection
set destFolderPath to (choose folder with prompt ¬
"Choose Folder...")
move mvfiles to destFolderPath
end tell
This is just one of several scripts; most if not all scripts executed from any other application that Script Editor falls prey to the same prompt. Substituting the tell to a specific application like Finder doesn't help.
I've written hundreds of AppleScripts for KM like this that always work just fine:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Finder"
set mvfiles to selection
set destFolderPath to (choose folder with prompt ¬
"Choose Folder...")
move mvfiles to destFolderPath
end tell
I just tested this in Script Debugger and KM, and it works fine.
MACRO: Test AppleScript
**Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/7/a/7a51f0c630ce97540062761726453e9286b536a4.kmmacros">Test AppleScript .kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
<img src="/uploads/default/original/3X/e/b/eb26e995857ca7436ebd8bd9c9e704f27ee4971a.png" width="663" height="517">
If this script/macro fails for you, then there is something wrong on your Mac, maybe as @peternlewis suggested, a corrupt Scripting Addition (OSAX), although as of macOS Mojave Apple does not allow or use user provided Scripting Additions.
As always, start with the simple troubleshooting. Do each, and test after each step.
1. Restart KM Engine and Editor app
2. Restart your Mac
3. Start your mac in [Safe mode ](https://support.apple.com/en-us/HT201262).
I have long struggled with this annoying message and was essentially blocked from using one 3rd party script addition going back to 10.7 and all the way up until Apple dropped OSAXen in Mojave. No forum and thread I've come across would offer the ultimate answer except for stating the reason for that behaviour, namely, that some 3rd party OSAXen might be at odds with security settings and aren't allowed to communicate with osascript from inside the tell block.
With that in mind, the main challenge became overriding that restriction. The solution that finally worked was to put the scripting addition's commands inside a script object instead of placing those inside an app's tell block directly and call the script object from that app.
Thus, the pseudo-code can be written as follows:
property x: initialValue
script A
3rdPartyOSAX_command_withValue:parent's x
end script
tell application "VideoPlayer"
<statements>
run script A
<statements>
end tell
This is related not to every 3rd party OSAX but only to those that spurred the security conflict so that's not an all-round solution.