Trigger macro from AppleScript while it's macro group palette is NOT displayed?

I don't know if this is possible. I have a macro group that is triggered with the "Shows/Hides a Palette" using a hotkey.

Each macro in the group has a hotkey trigger itself, but the hotkeys used are simply keystrokes without modifiers (command, option, ctrl, etc). Therefore, I do not want the macro group active unless the palette is being displayed; obviously if the group were always active then routine typing would trigger these macros.

I would also like to be able to trigger these macros from AppleScript. However, when I try to do that, I get an error back that no such macro can be found. If I display the palette, then the AppleScript will execute the macro.

This is not unexpected behavior, as I have found previously that macros in a palette can only be triggered if the palette is active, but what I really need is a way to set a macro group so that its macros can be triggered programmatically even when the palette is not displayed. Is there a way to do this? Am I missing something? (Note that the macro group itself is enabled; it's just that as far as I have been able to determine, macros I a macro group that is displayed as a palette in the way I am doing it are not accessible until the palette is displayed, and for the reasons outlined above due to the hotkeys I do not want the macros triggered by hotkeys unless the palette is showing.)

The only solution I have thought of is to create a macro group with the macros themselves, which are always enabled but without hotkey triggers and then a second group displayed as a palette, in which I create duplicate macros, each with a hotkey and just triggering the appropriate macro from the first group. This should work fine, but I wonder if I am missing something that would be a simpler solution.

Thanks.

The only way I can think of to avoid making duplicate macros of some sort for this kind of use case is to use the "Activate Macro Group for One Action" action before running the macro in question via AppleScript. If you're executing these AppleScripts via KM, you can just add the action before each "Execute AppleScript" action. If you're executing the AppleScripts some other way, you could make a new macro in a globally available group that just contains the "Activate Macro Group" action, then trigger that macro via AS right before the other macro, like this:

tell application "Keyboard Maestro Engine"
	do script "Activate Macro Group"
	do script "Trigger Macro"
end tell

The downside to this method is that the palette flashes on screen for the moment the macro group is activated, but if that's acceptable, this might be the simplest way to go.

Thank you....that would work but for the palatte flashing on the screen as you noted.

I decided to just create a macro group with the necessary macros and a second group which displays the palette. The macros in the palette group just each invoke the corresponding macro in the non-palette group. As a result, there is duplication, but if I want to update one of the macros I just have to update it in one spot, so that makes things a bit easier.

I wrote a KM macro that takes a specified macro group and builds the associated palette macro group, so it's less onerous as I can not only automatically generate the palette, but if I add macros to the first group I can just use the script to rebuilt the palette as well, so that does make things easier.