"Show Menu" fails if menu bar is hidden

Hello all,

Small issue with the Select or Show a Menu Item action: if the menu bar is hidden (either because an app is in full screen or because System Preferences -> General -> Automatically hide and show the menu bar is checked), then KM seems unable to show a menu.

Selecting a menu item works perfectly fine. But I’m talking about showing a menu. According to the wiki, “If you leave the menu item blank, Keyboard Maestro will show you the menu and leave it displayed so that you can then select the desired menu item manually.” It is this which does not work in the above scenario.

A workaround is to move your mouse to top of the screen, which reveals the menu bar, before triggering the macro. But that requires taking your hand off the keyboard, and what true maestro ever does such a thing?

Another workaround is to add, just before the Show Menu action, an action to type whatever keystroke triggers Show Help Menu (set via System Preferences -> Keyboard -> Shortcuts -> App Shortcuts; I believe the default is ⇧⌘/ ). This reliably reveals the menu bar, letting KM work its magic and show the sought-after menu.

So that is great. Nonetheless, I’m wondering if there’s a better way, or if a future update to KM might obviate the need for such workarounds.



I don’t have any better suggestions that the solutions you have suggested, which are probably a bit to hacky to add to Keyboard Maestro to try to work around the system behaviour.

I work with “Automatically hide and show the menu bar” on almost all the time. (I have one cross-platform (Qt5-based) development environment I use a lot that sometimes get tripped by that, so I sometimes turn it off, but usually it is on.)

Store the current mouse position in a variable, move the mouse to the top of the screen, show your menu, and restore mouse position. The problem is how to know when to restore the mouse position. Some possibilities, which I haven’t explored directly, are:

  • don’t bother (do you really need this? If you are displaying a menu, presumably you want to do something with it, so why would you need to restore the position?)
  • have a separate keystroke that restores the mouse to its previously saved position (I do this in some of my macros)
  • guess a time and Pause for that long before restoring the mouse position

Is there really a keystroke for hiding/showing the menu bar? If there is that seems to be the most straightforward solution. But really, why not just move the mouse?

I played around with some GUI scripting and convinced myself it was hopeless. Maybe someone could do this in JXA or whatever.

I found another workaround that shaves at least a milisecond off my initial solution, so it is obviously worth sharing:

Because KM’s Show Menu action fails if the menu bar is hidden, we need our macros to un-hide the menu bar just before triggering this action. Moving the mouse to the top of the screen, as @MitchellModel suggested, is one way to do this. But there are built-in macOS keyboard shortcuts that can do it for us, which I like better because then I don’t have to use the mouse.

One of these macOS keyboard shortcuts is Show Help Menu. This shows the menu bar, but then it also shows the help menu, which adds visual distraction and maybe a slight delay before KM triggers the Show Menu.

A better option can be found in System Preferences -> Keyboard -> Shortcuts -> Keyboard -> Move focus to the menu bar. This command merely shows the menu bar, without opening any specific menu, making it a little quicker (or at least visually less distracting).

So, use System Preferences to assign a system-wide shortcut to this command. Then add a “type keystroke” action to trigger it just before the KM Show Menu action. Works nicely.