Automate changing a macro's icon?

Hey guys, newly switched from QuicKeys to Keyboard Maestro. Trying to do something I’d always wanted to do in QK, but could never make work - maybe there’s a way to do it in KM?

Basically, I want to make a ‘notification palette.’ Say there’s a menu item hidden deep in a menu, and I want to query the program regularly (1 second seems to not actually cause any problems) and update the state of a palette item based on that menu item’s checked state.

I’ve tried it with just using the macro ‘mark’ function, but the green checkmark is a bit small to see at a glance. My ideal would be if I can somehow programmatically change the icon (say from a green square to a red square, or empty to checkmark) of a macro.

Any thoughts? I looked (briefly) into trying to applescript KM to do this, but it seems that the applescript dictionary is surprisingly sparse.

Thanks!

Would it have to always float on your screen (like picture-in-a-picture video)?

If not, you could make an Excel or Google spreadsheet, and update a cell’s color based on a KM macro

Ideally yeah, I want a floating palette that’s only visible when particular applications are running (probably different palettes for different apps).

Best solution I’ve managed to come up with so far is to have two very similarly named (both empty) macros (IE, “Macro1” “Macro2”) and have one with a checkmark icon, and one without, and have it activate/deactivate between the two depending on whatever state I’m looking at. Very clunky.

I'm not 100% sure what you want. I don't know what application you're using, nor what menu item you want to observe.

So here's a totally contrived example, but I believe it covers what you're trying to accomplish. I hope. If not, at least it's a start.


###PURPOSE:

Shows a Palette when Keyboard Maestro's Editor is visible. There's a macro called "State", and it will show a Checkmark icon when the Editor's Edit Mode is on, and a Red X when Edit Mode is off.

(This could be any application/menu condition, but since we all have this, it seemed like a good choice.)

###IMPLEMENTATION:

We actually have two "State" macros in the palette (and one other macro, explained below). One "State" macro is namad "01)State" and has a Checkmark icon, and the other is named "02)State" and has Red X icon:

We have a third macro called "99)Check Edit Mode", which when triggered, checks the Keyboard Maestro Editor to see if "View->Stop Editing Macros" is visible. It enables/disables the two "State" macros based on the result.

This third macro would not normally be on the palette - this is what you'd run on a timer. But I didn't want to mess with a timer, for this example.

So, when the Editor is in Edit Mode, after "Check Edit Mode" is triggered, we get this:

And when the Editor is NOT in Edit Mode, after "Check Edit Mode" is triggered, we get this:



And here's the macros:

Notification Palette Macros.kmmacros (7.7 KB)

Let me know if this is close (or not).

2 Likes

Yep, that’s basically what I’d outlined as my kludgy idea (which I’m already doing, now - but thanks for the confirmation and the much more readable example for any others that come across this post!)

As to the program, most of my ideas for this are with Pro Tools, and I’m actually not observing a menu item - I’m doing screen checks to see if buttons are active or not, though I’m sure I’ll find other triggers that I’ll want to keep status-updates on. I might also use it in Arduino, for various things (having a visual notifier of what processor I’m targeting will be very dandy for that).

Pro Tools is dumb and doesn’t put a large amount of it’s functions into menus, or give hotkeys for a lot of stuff. I have somewhere around 50+ QuicKeys macros for Pro Tools that I’ll be converting over, because there’s just so much UI stuff that the developers seem to not care about (joys of an ‘industry standard’ program, I suppose).

Interesting thing I didn’t know about is that 01) 02) etc, anything before the parenthesis isn’t displayed in the palette! That’ll make it much, much prettier.

Thanks!

There is no way to programatically change the icons of a macro.

The solution of enabling/disabling macros to make them appear seems fairly workable for this case.

An alternative would be to use a Custom HTML Prompt window, which you can communicate with to adjust the display in any way you like.

Yes, you can use that numbering scheme to order the items in the palette. I used it in this case, so it was easier to distinguish the macros, since they have the same name. Of course, if you’re only displaying icons on the palette, then the name is irrelevant.

As for looking for screen images, there’s no way you should be doing that every second. Big resource hog, even assuming it can accomplish everything in one second.

Well, you’re not wrong that it’s a huge resource hog - when I switch to Pro Tools, Keyboard Maestro jumps up to about 267% usage.

Though if I’m being truly honest - doesn’t really bother me. My machine maxes out at 2400% CPU usage, so I’ve got a ton of breathing room even if it’s using 2.5 processors just to make my life easier :stuck_out_tongue:

That said, I just did a few things that drop the CPU usage greatly - the buttons I want keyboard maestro to look for always show up in the same screen area, so giving it a small (about 50x60 pixels) area to search in, instead of the whole screen, greatly reduced CPU usage. A few of the buttons I was looking at do in fact have menu items, so those are no longer screen searches, too.

That’s good!

And I understand about not really caring about the CPU usage - that’s why you bought the computer in the first place, right? Let it do the hard work!


,

Instead of struggling to do with only one notification palette, I suspect easy to do with multiple palettes.

Each palette only one macro.
Each macro in its own macro group.
Macro can be “null”, but will have a unique icon – any icon you wish.

Repeat and switch/case action can activate/deactivate each macro group.
The little icons will appear/disappear as notifications change true/false.

Make them “blink” if you wish.

I haven’t tried this and I don’t intend to.
But if I had to, that would be my approach.