Applescript won't activate KM Macro

Running in OS 10.11.6. with KM 8.0.4.

Have a wonderful printing macro that works within an application group just fine when activated by a Hot Key trigger. But when trying to activate via an Applescript trigger on that same macro, in the same group . . . no soap.

I keep getting an error window that states:

“do script found no macros with a matching name
Keyboard Maestro Engine got an error: do script found no macros with a matching name (-1)”


“Script Error
Keyboard Maestro Engine got an error: do script found no macros with a matching name”

All my other macros within the same Application’s group work fine, but they are all activated via Hot Key triggers. If I switch them to activation via Applescript using the script provided by KM, I get the same error.

I read up on all similar posts regarding this problem, but have been unable to rectify it with any of the suggested remedies.

After much experimentation, I have found that the macro WILL activate via Applescript if I place it into the Global Macro Group, and direct it to firstly activate the application it is intended to work within, but that seems like a lot of trouble to go through, especially with windows and apps lighting-up, back and forth. Seems overly problematic. I’d prefer to keep it all within the confines of it’s intended application.

Please tell me that it isn’t 10.11.6, and that there is a fix, or that I’m just missing something.

I’m open to all suggestions. Thanks.

I just tested this with one of my app-specific macros, and I get the same error message as you when I run the AppleScript when the app is not frontmost. However, it works fine as long as the app is frontmost, so I’m fairly certain the trigger is failing because you aren’t in an application from the relevant application group when you try to trigger the macro via AppleScript. That’s why placing the macro in the Global Macro Group makes it work (since macros in that group can, by definition, be triggered from any application). I don’t know how exactly you’re triggering this macro via AppleScript, but as long as you do so while the application(s) in the relevant application group are frontmost when you do, I think you should be fine.

Yes, you can only trigger macros if they are active, including via AppleScript. There are very few exceptions to this.

The application is frontmost.
Why else would it work with the Hot Key, yet not the Applescript - since both are activating the same macro, and both whilst the application is frontmost.
I have even added the “Activate a Specific Application” action at the head of the macro, to be sure it is in the correct application, but with no success.
Again, if it works with the Hot Key, shouldn’t it work with the Applescript?

The application (a database management system) allows for custom buttons that can fire off an Applescript. I have it doing so, from within the database, as it is running. I’m not an Applescript maven, but I can get the database to fire off the several simple scripts I have written, without any problems - all from within the application.

Any suggestions would be greatly appreciated.

BTW, I absolutely love KM! Speaking as an old QK’s man (from all the way back to the black & white System 7 days).

In that case, it’s definitely strange that you’re running into this error, since as Peter (KM’s developer) confirms above, this error almost definitely means that the macro is not active (i.e. it can’t be executed because the conditions set by its app-specific macro group are not met) when you try to trigger it via AppleScript. Without any more information, I can only guess that this app’s custom AppleScript buttons use a different process than the rest of the app that cause the application group’s criteria check to fail when the AppleScript is run. Can you please post the macro in question (preferably in both macro file and screenshot form) and tell us exactly what database app you’re using?

One more note:

With the way KM works, I’m afraid this won’t solve activation related issues as long as the macro this action is part of is in a non-activated group, since as long as the activation conditions are not met, the macro will not run, which means the app will in turn not be activated.

Glad to hear you’re enjoying KM! I never used QuicKeys myself, but from what I’ve read from other former QK users, I’m wondering if there may be some QK habit left over that is at odds with the way KM works in a way that isn’t immediately obvious (which is all the more reason to post your full macro here, to help us get to the bottom of this).

The database is Helix Rade. It has the ability to add buttons to forms which control internal commands that the database acts upon. These buttons can also allow for the opening of an external application or file. i have used these before to open and fire an Applescript that has been saved as an application. I have it doing some simple Applescripts that I wrote - nothing too heavy-duty, as I’m not much of an Applescript writer.
So I set-up my KM macro (which goes back into Helix, opens a specific form, and via tabbing it copies to KM named clipboards all relevant data, then opens an “Send Mail Message” and pastes, via the named clipboards, all that info into it’s fields for ‘email address,’ 'subject," etc. and sends it off, then returns to Helix.
It works slicker than snot when I use a KM Hot Key to activate it! The problem is, there are about 50 of these various forms in Helix, and each has different fields and such, making it necessary to have 50 KM macros, and thus would need some 50 different Hot Keys. Quite cumbersome and confusing to the end-user.
The solution seems simple enough, just assign an Applescript trigger to each of the macros, and have each of the Helix forms, via a button on each, open it’s corresponding Applescript to activate it’s assigned KM macro.
Here is where I run into my problem. Helix does all that’s asked of it, and attempts to open the Applescript, but I keep getting an error window that states:

“do script found no macros with a matching name
Keyboard Maestro Engine got an error: do script found no macros with a matching name (-1)”

BTW, If I try running the same Applescript through the Script Editor (not through Helix), I get this window:

“Script Error
Keyboard Maestro Engine got an error: do script found no macros with a matching name”

I’ve tried everything, a full week of night’s rebuilding and testing, but so far, no soap.
I am open to ANY suggestions.
Perhaps possibly some other way of triggering the KM macro from within the Helix application?
I’m wondering if there is a straight Applescript that can control KM and open one of it’s macros? Perhaps typing out the Hot Key that would activate the KM macro?
Thanks in advance for your assistance. I look forward to your feedback.

KM Newby,

Hey Rich,

I’m afraid I’m not familiar with Helix Rade, but if the issue is an alternative way of being able to easily choose from 50+ macros, one suggestion I can make is to forego the AppleScript button solution altogether and use a palette; specifically, a conflict palette that appears automatically when multiple macros are assigned the same hotkey. I and many others find this a great way to use large sets of macros that don’t lend themselves well to setting unique hot keys for each one. Once a conflict palette is triggered, it can then be used to select the macro you want by clicking on it in the palette, or you can type to filter down to the macro you want by typing the macro’s name. Once you have typed enough letters of a macro’s name to uniquely identify it, it will then be triggered. If you’d like to try this method, I recommend looking into this set of macros I wrote for KM8 that makes it much easier to assign the same trigger to multiple macros: KM8: Copy, Paste, and Batch-Delete Triggers

Another option is to skip the conflict palette step (or use this method in addition to it) and simply type the name of the macro you want, rather than its hotkey. This can be done through popular launcher apps like Alfred and LaunchBar, or it can be handled entirely within KM using the Trigger Macro by Name action.

There are other methods that can make working with large sets of macros easier (like the status menu, or other types of palettes that can be set to appear whenever you’re in a certain app) but I’ll hold off on those for now in the hopes that one of the options I’ve described here sound useful. If you’re not sure how to proceed with any of these options, or they don’t end up resolving your problem, feel free to report back!