How to quickly select macros within an "expandable" Palette

Is it possible to do the following:

Whenever the cursor is on the “expandable palette” (therefore “expand” the palette), use a keystroke (without modifiers) to trigger a specific macro within that palette.

This is what I mean by “expandable palette”

CleanShot 2025-10-16 at 13.54.27

Here is the context if needed. I am open to any alternative methods that can achieve the same thing.

On the WhatsApp Desktop app, I have 10 palettes and the macros within them basically select specific stickers in the sticker pack and send it in the chat.

I want a hotkey to expand the palette (so I can see what macro (stickers) are inside that expandable palette), then I would like to use a single keystroke to select a sticker (e.g. press 1 to select the first sticker).

Right now, I have another macro that moves the cursor to the palette to expand it and it is triggered by a hot key (As far as I know, there’s no other way to expand a “shrunk “ palette?). Then I select the sticker (macro) manually. But that’s pretty slow.

CleanShot 2025-10-16 at 14.15.41

The main problem is that KM has no way to determine the location and size of the palette, at least not without some Find Image wizardry, or without your concurrence that the window will always appear at a specific/unchanging place and size. The second problem is how do you, as the user, know which number works for which sticker? One of your palettes has more than 10 stickers, so how do you specify a sticker that requires two digits? You need to define the problem more clearly.

Well I am ok with the palette always appearing at a specific place on the screen and the “size” will always be 4 columns (more rows might be added in the futures) when I expand the palette.

1 will be assigned to the sticker at the leftmost corner of the palette. Then 2, 3, 4, 5…as I go from left to right, top to bottom

Assigning numbers to stickers

I can use Letters after 1-9 (e.g. Q=10, W=11, E=12…). But for now I only want to assign numbers for the top 8 stickers that appear at the top of the palette. The 8 stickers at the top of the palette will be used most often, therefore I want to use shortcuts to access them. For the less used stickers, I can simply select them with mouse clicks.

If we predicate on the assumption that the place and size of the palette will remain the same, would it be possible do what I mentioned?

Also, I found a potential workaround, I copied and paste each macro group (the palettes). Whenever I want to select a sticker with a shortcut (rather than hover over the paletteand select with a mouse click), I can use a hotkey to bring out the copied palette for one action (and it appears at the same place as the original palette, making it looks like its the original palette to open up) → press a number (which select and send a sticker) → Palette closes by itself at the end.

Here is what it looks like in action
  • + Q → Open copied palette
  • 1 → Select first (upperleft corner) sticker

CleanShot 2025-10-16 at 16.28.45

The main problem with this approach is that whenever I make a change or add a new sticker to one palette, I have to do the same for the other copied palette. Is there a way to “sync” both macro groups? I think I have to use some sort of set “variable” actions in the original macro and call it in the other copied macro, but I’m not sure how to go about it exactly…

Of course. But I'm all out of energy today.

I have no idea how to help you there if I can't see your macros.

1 Like

No worries! I am in no rush!

I will show you later after you get some good rest! :wink:

Are these WhatsApp palettes (and if so, how? A quick search doesn't get me any hits), KM palettes, something else?

Setting a hot key trigger as an unmodified keystroke is generally a bad idea in any context where you might also use it as a "normal" keystroke -- for example, a chat app. Especially if you can't use window titles to control the macro Group's availability. KM will always swallow the keystroke and run the macro, so you'll have to include logic as to whether or not to (try and) pass that keystroke to the app.

@Willis Please excuse me if I misunderstood. You already have a macro and a shortcut that opens these palettes with the funny icons.

For example, control + Q. This macro could also activates macro group or a KM palette, small in a corner.

This KM palette activates a macro with the single key trigger “1,” which searches for this image and then clicks on it.

Finding this image should be no problem for KM. So it doesn't matter where the palette opens. If you run out of numbers, you can use A, B, C, etc.

Okay, I think I have a demo working. I'm not 100% sure if you will like it or if I'm understanding you correctly. but this macro will create 8 transparent buttons over a fixed area, which you will determine by measuring the coordinates of the rectangle. You will place those coordinates into the four variables at the top of this macro.

Remember, it's a demo, and so it may have minor deficiencies which can probably be fixed. This demo just moves the mouse to the correct location specified by your number 1 to 8. If you don't like it, that's fine. I enjoyed working on it. I did get some assistance from AI, but I definitely did some of the work myself.

Press 1 to 8, macro clicks there Macro (v11.0.4)

Press 1 to 8- macro clicks there.kmmacros (6.6 KB)

I hope that by "sticker" you mean palette item, aka macro. Otherwise none of the rest of the post is relevant and should be ignored.

Another toggle job with GUI scripting, duct tape and baling twine.

Here are 2 macro groups. One with a single macro and the second with 5 macros.

Palette Clicker macro and Palette Hotkeys macro group allow using one of 5 single hotkey triggers to click corresponding macros of an expanded palette.

Put your existing cursor mover at the top of the macro Palette Clicker. It will be needed to expand the shrunk palette.

The macro Palette Clicker activates a single action only macro group, "Palette HotKeys", which has 5 macros triggered by single digits 1-5. Each macro sets a global variable, "PaletteIndex", to a the corresponding number.

5 macros

Because the group is set for one action it deactivates on a single keystroke. It also deactivates on context change and any of the other usual things that make a single action group deactivate.

related Conflict Palette info
Palette HotKey Group Image

The main macro is also set to listen for deactivation and will finish up if that happens.

Meanwhile, in the main macro, a Pause Until variable PaletteIndex is not empty OR Palette HotKeys group is inactive--has been waiting.

It now stops waiting and lets an AppleScript import the PaletteIndex and click the accessibility button at PaletteIndex of the first window of the KMEngine.

AppleScript
use AppleScript version "2.4" -- Yosemite (10.10) or later
set paletteName to ""

tell application id "com.stairways.keyboardmaestro.engine"
	set paletteIndex to (getvariable "PaletteIndex") as integer
end tell

if name of current application is not "osascript" then
	set paletteIndex to 1
end if

tell application id "com.apple.systemevents" to tell application process "Keyboard Maestro Engine"
	try
		set paletteName to name of window 1
	end try
	try
		tell list 1 of window 1
			tell button paletteIndex to perform action "AXPress"
		end tell
	on error msg
		return paletteName & linefeed & msg
	end try
end tell
tell application id "com.stairways.keyboardmaestro.engine"
	setvariable "PaletteIndex" to "%Delete%"
end tell
return paletteName

If the cursor has hovered over and expanded a shrunk palette, that window should move to the top of the Z-order and indeed be the first window. When 1 or more expanded palettes exist, there is always a chance that the wrong one will be top of the Z-order. If window 1 is indeed the intended target but unexpanded, the script will fail and a notification will contain the error message.

For good measure there is an Escape key macro in the Palette HotKeys that deactivates the group when escape is pressed. The macro sets the PaletteIndex to "deactivate". The main macro finishes up without Executing an AppleScript

Things that can misfire:
you click the button index of the wrong palette
your initial numeric key press is intercepted by KM

Who knows what else...this GUI scripting. :wink:

Palette Clicker image


Updated to v1.1:

Moves cursor over palette before user clicks.
Main macro is a subroutine.
It defaults to targeting the currently focused palette.
Calling macros can specify a palette to target.
Fixed Escape macro to deactivated its macro group.

Palette Clicker and Palette HotKeys v1.1.kmmacros (34.8 KB)

Thank you all for bending over backwards helping me with this! I’m going to take a look at each one and respond to it one by one!!

They are indeed KM palettes, they are “expandable” because in the palette setting, I ticked the “Shrink“ box.

I think this issue may be resolved by activating a palette first (which I set it to “Activated for one action“), only then will I get access to the macros within that palette (which use an unmodified keystroke as a trigger), and after the pressing the unmodified keystroke trigger once, it will deactivate the palette by itself so that it will not affect “normal“ keystroke afterward.

However, problems arose if I activated the palette and decided not to press a keystroke trigger, which is something that bound to happen, either because it’s a “sticker” (macro) further down the palette list and I don’t have a trigger for that, so I have to click on it. OR I decide not to use the sticker after all. In both scenarios, this will leave the palette activated until I press one of the unmodified keystroke that will trigger the macros, which will interfere with “normal keystrokes “ when I type in the chatbox. Oh so I guess it is a bad idea after all…

But I’m hoping maybe I can get around that by including something in the macros that will deactivate the palettes (hence the “normal” keystroke will no longer be a hotkey trigger) when I do these actions:

  1. A mouse click (clicking on a sticker or anything else)

  2. Mouse cursor moving away from the palette

  3. A single hotkey that deactivates the palette

I’m still working on it…

Yes, you are correct!

Control + Q will activate the KM palette, then a single number key (“1“) will click on the image (macro).

I got this part down. The problems I am having as a result of this setup is what I mentioned just now above:

However! I have made some changes to my macro groups and macros last night, so the setup is a bit different!

I should show you all my latest version first before I proceed, so hopefully there will be less confusion.

The more exceptions you want to manage, the more complicated it gets :slightly_smiling_face: The simplest solution is short/long press. This always works.

1 briefly tapped --> types 1
1 held longer --> executes the macro

Since you don't often need numbers when typing normally, this doesn't interfere with normal typing

This is a summary of what I have right now:

I have 12 expandable Palettes that only activate when I open up the WhatsApp desktop app.

The Palettes will always sit in the places you are seeing now. When a mouse cursor hovers over the palette, it will expand and show the macros within it. Every palette will always have 4 columns and varying rows (as I add or delete the stickers (aka macros)).

Palette format

CleanShot 2025-10-17 at 17.21.46

When a sticker (aka macro) within the palette is triggered (either by clicking on it and using a hotkey to trigger it), it will select and click on a sticker in the sticker pack and send it to the chat.

Example Macro

Seeing the Macro in Action

CleanShot 2025-10-17 at 17.29.42

To speed the process of selecting stickers, I created two additional macro groups:

1st macro groups:

  • Control + Q will activate this macro group for ONE action
  • Then, a single letter hotkey is used to trigger each macro within each macro group
  • There are 12 palettes, so I have 12 single letter hotkeys to trigger each one
  • The actions of these macros are to move the cursor to the palette so that it “expands“ AND it activates the 2nd macro group (that I will explain in a bit)
  • As an example, “Control + Q” will activate the 1st macro group → Single letter “Q“ will move the cursor to the first palette, therefore expanding it + 2nd macro group is now activated
Example Macro

Seeing the Macro in Action

CleanShot 2025-10-17 at 17.45.12

Triggers for each palette

2nd Macro groups:

  • 2nd Macro group is activated (for ONE action) by the actions of one of the macro of the 1st macro group
  • Similarly, for the macros in the 2nd Macro group, a single letter hotkey is used to trigger each macro (stickers).
  • I have varying number of stickers (macro) in each palette, and I only have hotkey triggers for first top 12 stickers. This means not all stickers have a hotkey trigger.
  • The actions of these macros are to click the corresponding sticker (macro)
  • As an example, after the cursor is moved to a palette and expanded it (by the actions of 1st macro group): Single letter “Q” will click on the 1st sticker in the palette. (The whole sequence would be: Control Q → Q → Q)
Example Macro

Seeing the Macro in Action

CleanShot 2025-10-17 at 18.08.36

Triggers for each stickers in a palette

This setup works just fine except for the problems I mentioned above.

I know!!!:sob:

This is actually an excellent solution! And I can definitely use that for my other stuff (thx!). But in this particular case, because I use WhatsApp a lot and on average send more than 50+ stickers per day. Those tiny 0.5 seconds during long press add up quickly over time and it’s not fun when u have to do it every time. I have used WhatsApp for a long time and I plan to keep using it, so it would be ideal to find a “quicker” solution. But I’m out of league here! :sob::sob::sob: .

CleanShot 2025-10-17 at 18.38.18

Wow this is pretty cool! didn’t even cross my mind it’d be possible to put some transparent buttons over your screen like that!

But in this case I think a simple mouse click action (trigger by a hotkey) will do the job just fine?

You know what this macro would be great for tho (for me)!? Placing those transpartent buttons over/beside YouTube videos and selecting them using the number / letter keys! The whatsapp palettes here is really structured so I don’t really need a guide (the transparent numbers), but its a different story for youtube videos!

Kinda like this! Transparent numbers beside each video and I can press a number to click on the corresponding video! I am gonna have to learn what those alien HTML stuffs in the macro are first! I might ask you about it later in another post!

Edit: I don’t think I’d use it here so you don’t need to fix this, but just want to point out that the transparent number buttons are covered by the stickers (macro) when the palette is expanded. Not sure if this can be fixed

Yes that’s what I meant!

I like this methods! It allows me to select the correct macros (stickers) within the palette even if the palette has been moved to a different place. In my method, the palette has to stay there forever and won’t work if it’s moved to a different location! (since it is based on “click” actions). Although I won’t really move the plattes around in the first place.

This is good! This is one of the “workaround” i was hoping to have

Yeah I think there might be some issues here.

Like you instructed I hover the mouse over a palette, using a hotkey to trigger the “palette clicker” macro, which then activate the “Palette Hotkey” macro groups, press 1/2/3/4/5 then it will trigger the corresponding macro in that palette.

The issue is it doesn’t work every time. It would worked one time, then the next attempt will always fail. I have to “cancel all macro“, try again, then it would work one time again then all subsequent attempts will fail.

CleanShot 2025-10-17 at 19.47.35

There’s some really good suggestions and macros here. But they all involve something more advance that im not familiar with yet (like the applescript and the html stuff), and it would be very difficult for me to tweak and change things on my own with your macros at this stage.

Therefore, if it is at all possible, could we use what I have shown you earlier (Here) and work something out from that please? Thx!

I didn't anticipate that my Custom window would be behind your app's window. I'm not sure whether or not I can fix that. It may be possible. But you don't want it so I may not seek the solution.

I suppose I could implement that, although for well behaved apps, like most web browsers, macOS has a feature that numbers elements like that, in the Accessibility section of System Settings. What you do is turn on Voice Control, then speak the words "Show Numbers" and those links on the right side of the browser window will have numbers displayed next to them, and you can say "Click 21" and that item will be clicked.

I can't (easily) take a screen shot of those numbers because the screen shot utility does not actually capture those numbers, even though they are on the screen. Those numbers are on some hidden screen layer that cannot be captured. I recommend that you check it out before I write more code.

I designed my macro to let you easily change the location of the window.

I looked it up. I prefer to use a single character hotkey for things that I have to do over and over again like clicking on videos, and voice control is not really customizable unlike your method. I might come back to your macro later when I learn some HTML and Javascript stuff.

It’s nice that I can choose the dimension of each “button,” but if I want to change the layout (e.g. adding more buttons), then I will need to know some HTML.