Trigger a macro when a palette appears

Hi everyone
I've been having lots of fun with Keyboard Maestro and have been doing my best to read up all the great discussions in the Forum, thanks to everyone.

I'd like to work with Palettes, some with mouse clicks and others with keyboard shortcuts. My personal design devil is having a challenge with the limitations of the palette UX options, so tried to figure out what I might be able to change. I found that I could add some padding using "bounds" in AppleScript, and with some fiddling, got a palette that I can work with.

I set up Macro Groups with a single keyboard trigger, using the app and window names filters to limit where a palette would pop up; no challenges there.

Where I've run into a wall is on how to trigger my format AS script, and use KM to move the palette to center screen, after the palette has appeared.
I managed this by using "If all Conditions met", where I used the same Application and Window Name filter logic, to then "Show Macro Group" and then both run my AS script and use KM to center the palette.

Wanting to still use a single keyboard trigger, I have now run into the conflict palette, as although the "If all Conditions met" checks to see if a palette should be opened, the single keyboard trigger does not have the preset Macro Group filters, so triggers the conflict palette.

I did run both the scenarios independently, so one with just using the Macro Group Filters and the second just running the open and format macros.

Questions?
A. Can I auto trigger a macro after just using the Macro Group palettes, once the palette has appeared (i.e. AS padding and KM to center palette)?
B. If not, any way of keeping the single keyboard trigger if I have to go the "Show Macro Group" route?

Hope the screenshots below help.
Any advice would be very appreciated :=) M

Hello Marcus (@Marcus513) :waving_hand:

As there’s no native trigger method in KM for letting it run Macros automatically at the moment a palette appears there is only one way for you to achieve this.

Instead of giving palettes a Hotkey in the settings you need to build calling Macros for these palettes whose will get fired by the preferred Hotkey.

Within such a caller you explicitly specify to pause with a script condition to wait for a specific palette window in KM Engine‘s Window List and then call whatever Macro(s) you prefer asynchronous. I have plenty of them on my Macs for years now and it works great every day they’re in use.

That’s the way… you’ve no other chance doing this saving system resources.

I hope I did help you with my reply. Let us know how it’s going. And remember to reach out for help if you get stuck. Good luck.

Greetings from Germany :germany:

Tobias

Lieber Tobias
Herzlichen Dank für die Infos.

I think I get the idea of what you propose, but am a little fuzzy on "a specific palette window in KM Engine‘s Window List" et cetera.

I tried a nested If/then structure, just adding the different "If All Conditions Met Execute Actions" conditions; it works but it quickly gets really messy.

I'm trying to build a hierarchy of palettes from top global down to app/window specific. Would therefore love to have a macro per palette, just to keep the admin of the whole thing nice and clean.

Might you please be able to share one of your macros with me, so I can do a deep dive into your clever logic?

Liebe Grüsse von einem alten Auslandsschweizer an der wunderschönen Pazifikküste in Washington.

Marcus