Macro responds to "do script" if called by UUID but not by name

An AppleScript "do script" is not running a Macro when called by name but runs it when called by UUID. Other test Macros don't respond to either.
versions KM 8.2.4 ; AppleScript 2.7 ; MacOS 10.13.6

I've searched these forum messages and checked all the suggestions. Still no luck.
https://forum.keyboardmaestro.com/t/error-do-script-found-no-macros-with-a-matching-name/5735
https://forum.keyboardmaestro.com/t/el-capitan-10-11-6-and-keyboard-maestro-engine-got-an-error-do-script-found-no-macros-with-a-matching-name/4448/3

The Macro to test an AppleScript is pretty simple:

It is enabled and sits in the Global Macro Group which is also active and unrestricted

This AppleScript is run from the Script Editor:
tell application "Keyboard Maestro Engine"
do script "4379B59B-EC3A-4E02-BB08-D92A178995A3"
delay 2
do script "€œDecrease Sound Volume"
end tell

The first call to do script works.

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

The UUID and the Name refer to the same Macro. (UUID came from "Copy as UUID")

Peter's checklist:

The normal cause for that is trying to execute a macro that either:

• Does not exist. (exists)

• Is disabled. (enabled)

• Not in application specific group (Global Macro Group)

• Is in a Macro Group that is disabled. (Group enabled)

• Is in a Macro Group that is currently inactive. (Group always active)

Any other suggestions?

Please post your macro file and image using post/upload your script/macro.

Please post your script as text using Code Block.

None of the images you posted can be viewed.

Did you get you AppleScript for the script from the Trigger popup for "Or by script"?

image

If so, then it will work provided the Macro Group and Macro are active when you run the script. See Macro Activation .

Hey @shiva88kr,

Hmm.

A quick test works fine for me...

tell application "Keyboard Maestro Engine"
   do script "Beep!"
   delay 0.5
   do script "9A1594A8-5C9F-412C-96AE-F66E83C47D5E"
end tell

The most likely problem is that your macro name is not correct for some reason, so make sure it's verbatim.

tell application "Keyboard Maestro"
   name of macros whose id is "9A1594A8-5C9F-412C-96AE-F66E83C47D5E"
end tell

Exchange with your UUID and run the script from the Applescript Editor.

Also – make certain you don't have any duplicated names.

tell application "Keyboard Maestro"
   name of macros whose name contains "Decrease Sound Volume"
end tell

If none of that helps then report back.

-Chris

@JMichaelTX, I found the problem using "https://www.diffchecker.com/diff"
When I used your suggestion and copied the script from "Or by Apple Script:" it ran fine both ways -- UUID or name
So I compared my original script versus the script generated by "Or by Apple Script:" in DiffChecker.
The problem was immediately visible … two hidden characters had crept into the name during a cut and paste when I created the script. I don't remember where I copied the name from.
Deleting those invisible characters in the name fixed the problem and the script runs fine now.
Thanks for your help.

1 Like

@ccstone Thanks for your script to reverse lookup the name from the UUID. It used it and the result looked like I had the right name, but I did not know I had invisible characters in the name :exploding_head:
It was diffchecker that spotted them
Please take a look at the image in the post above.

1 Like

I've had that happen to me before. It's a pain to find when you don't know what to look for.

:skull:

After pulling my hair out to find this problem the first time, it's one of the first things I check for when reference-by-name isn't working.

My go-to tool for spotting invisible characters is BBEdit.

Paste your text into a text window.

Hit I to “Show Invisibles”, and voilà!

Glad you found the trouble.

-Chris

1 Like