Error: "do script found no macros with a matching name"

I have followed the instructions here1 to invoke a macro from an AppleScript script. Unfortunately I get the error:

error "Keyboard Maestro Engine got an error: do script found no macros with a matching name" number -1

The script is as simple as you’d expect:

tell application "Keyboard Maestro Engine"
	--- do script "Copy project ref"
	do script "254D4F5E-7A25-43AD-9EA8-55D06310BACF"
end tell

What am I doing wrong?

The long number number in between the quotes,

do script "254D4F5E-7A25-43AD-9EA8-55D06310BACF"

Is the macro’s UUID. The error message indicates that you don’t have a macro with that UUID.

For the macro you want to run, in the KM Editor, click Edit->Copy As->Copy as UUID, then paste its value in between the quotes.

For the macro you want to run, in the KM Editor, click Edit->Copy As->Copy as UUID, then paste its value in between the quotes.

That is exactly how I got the UUID of the task.

Oh, I know what it is. The macro or its group isn’t enabled/active. I’ve been confused by this error message before.

Hmmm, that’s an interesting explanation, but it’s not the case. Thanks.

I’ve actually tried different macros either by UUID or name and cannot get any of them to execute. All resulting in the same error. So I think:

  1. either there’s a permission issue somewhere
  2. or the feature doesn’t work on 7.3.1 on macOS 10.12.1

I will be extremely surprised if your issue does not turn out to be that the macro is not currently active.

How are you executing the AppleScript?

Add a Status Menu trigger to the macro in question and verify that it is appearing in the Keyboard Maestro status menu.

1 Like

If the group is active for a specific application only, is that also the case that when called from an applescript it won’t be found?

Correct. A macro must be active for it to be available to be triggered, including via AppleScript, URL or whatever.

If you want a macro to be active sometimes, but trigerable by script at other times, move the macro actions to somewhere globally active, and then have the macro use Execute Macro to execute the sub-macro.

1 Like