Select, Not Toggle

Is there any function built into Keyboard Maestro that can allow me to select somethingn from a menu and make sure it is on (or off) rather than toggle it? There are so many times in applications where they have menus where you check or uncheck it by running the menu command. Usually they show a checkbox or not so it seems that getting a screen state is the only way to do this.

In short is there anything reported back to the system if a menu item is a toggle and what state it is in? I want always make sure menu items are either on or off and not toggle.

One option would be to look for an image of the check-marked menu item, after KM opens up the menu.

You’ll need to get a screenshot of the opened menu, which might be challenging. But I suspect there’s a KM method of getting a screenshot that might work - something on a timer. If not, you could try a program like Snagit.

If you have trouble figuring out the macro, just ask. I’ve been doing a lot of “find image on screen” actions lately (though, none with menus), so maybe I can help.

You can get the state of checked/unchecked menu item using AppleScript and System Events UI Scripting, but it can be a challenge.

The hard part is identifying the UI element that contains the menu item of interest.

This article may be of some help, at least to get you started:
Keyboard Maestro and UI scripting

May I ask which app in which you would like to get the state of the menu item?
I might do some testing if I have time.

Thanks for the help, I will try UI Browser and have used that in the past with it often not working after updates (no fault of UI Browser of course). I am using Cubase which is not all that accessibility friendly, though they speak of it being that way with different updates.

Hey @skillet,

Keyboard Maestro's If Then Else action has a menu condition with many options:



Dang, there it goes again - I keep learning new things. I’m becoming addicted to reading this forum, which of course isn’t a bad idea at all.


Chris, thanks for reminding us of this great feature.
KM's feature list is truly exhaustive! :thumbsup:

So glad I asked about this, it felt like a shot in the dark, that is wonderful Keyboard Maestro is truly amazing! Keyboard Maestro even found it in a submenu, it took 5 seconds to find it and make sure. “Is Enabled” didn’t work for me but “Is Marked” worked, it shows up as a check in the menu. I guess the menu reports back in different ways. I’m scratching my head about the difference of “Is Not Marked” vs “Exists but is not marked” they both take the same amount of time to find and execute for me.

“Enabled” means “not greyed-out”.

Good question about the other thing - the Wiki doesn’t say anything about it.

“marked” is Apple’s parlance for what users probably normally would say “checked” but can be marked in different ways.

The difference between “is not marked” and “exists but is not marked” would be that the former is true if the menu item does not exist, whereas the latter requires the menu item to exist, but to not be marked. Same for “is not enabled”.

1 Like

Thanks for the help, I was able to speed things up from 4 - 5 seconds (on late 2013 Mac Pro, trashcan model) through using "With Path" so it didn't have to go searching. It is nearly instant now with that option, thank you Peter for adding so many fantastic options to Keyboard Maestro! Long live Peter!!

The help links from the Macros now are so very helpful and speed this process up significantly, in this case to learn what was needed for the menu item separators.

I love that it shows "Currently True" or "Currently False", I know that has been there a while but sending more thanks on making things easier.



I'd missed the “with path” option of the Menu Condition.



Oh good, I am glad I could reciprocate something to someone that has helped me so many times!! I wouldn't have found it without you in the first place.

1 Like

@peternlewis maybe you can shed some light on this and if there is a way to do this. I have a menu item that doesn't have a check but is greyed out when a function can't be performed and in black when it can. There are two menu items that generally are not lit up at the same time (though they could be). I want to make a macro that if one is greyed out then it performs the other task and vice versa. I am okay if the macro fails if they are both lit up or just does both.

My issue is that it doesn't appear that Keyboard Maestro can detect greyed out menu options or at least not in this case. I have gone through every option I can find and nothing detects when a menu is greyed out. I am not completely clear on the difference between "with this name" and "name matching" in the If any of the following are true.

Here is screenshots of the menus "Events to Part" greyed out.

"Dissolve Part" greyed out, I want to do one or the other with a single key command.

"Greyed out" means it is disabled.
"Black" means it is enabled.

I think you probably need something like this:

1 Like

Yeah I tried that and it didn’t work, I guess Cubase 8.5 is not reporting it as enabled or disabled.

Could be. Or not updating its menus at all. Or you have misspelled the menu name.

You can try opening the Audio menu first (with Show Menu Audio ➤) and see if that helps the condition work.

Otherwise you may be out of luck.

1 Like

For this reason I use Keyboard Maestro dropdown menus to find things just incase. I remember when Tiger introduced adding your own key commands and things like ellipses ... Would have to be a real ellipsis and not just 3 periods so I am always leery of those kind of things.

Is this to just wake the menu up? This is actually a great idea and one I use to open up recent documents and have it stay open. I reminded that you have to create an empty menu item to have it toggle the menu open to stay open. This is nice and I think I am going to start using this to see what menu items are being used when I run macros that do things in menus.

I was able to finally get it to work by creating it off of Dessolve part instead and didn't need the toggle menu open (though I am keeping it). I was only trying "Events to Part"

Keyboard Maestro “Toggle Events to Part and Desolve Part” Macro

Toggle Events to Part and Desolve Part.kmmacros (33 KB)

You will be happy to know that Keyboard Maestro treats ellipses and three dots interchangeably, so it wont care which you use. But other things can cause problems (like strange unicode spaces for example).

Yes. To force the application to update the menu.

Thanks for the help and info Michael and Peter.