What's the best way to work with mini-menus? (NOT the menu bar)

I had a number of macros in QuicKeys for mini menus inside various app windows. A familiar example, for most, would be the "From" mini menu, in a new Mail.app message, which allows you to select the address from which you'd like to send that message (if you have more than one email address). I have a few addresses, and in QK I used keyboard triggers to click on the mini menu and select the desired address.

In QK, after clicking on the mini menu, I could specify the item to be selected by name. But so far, I don't see a similar action in KM. Have I overlooked it?

I'm aware of the Click/Drag action, but the problem (in Mail.app) is that after clicking on the mini menu, the distance to be dragged changes, depending upon which address happens to be displayed at the time. So it's not possible to reliably indicate the distance to be dragged.

How do you guys deal with mini menus? Is it possible in KM to select options from a mini menu by name?

Hey @soundsgood,

Unfortunately Keyboard Maestro doesn't have a mechanism for directly dealing with pop-up menus – the user has to resort to AppleScript UI-Scripting to manage them.

In this example the way to manage is to create a shortcut in the System Prefs > Keyboard > Shortcuts > App Shortcuts > Mail.app > <Exact format of sub-menu item in pop-up>

I have 7 keyboard shortcut for directly selecting different addresses:

image

I also have a macro to pop-up the menu for type-select to pick up a few I don't bother to have keyboard shortcuts for:

Pop-up Menu ⇢ Open ⇢ Outgoing Message ⇢ FROM.kmmacros (6.2 KB)

-Chris

Popup menus are tricky to control. To select a popup menu, you need to simulate a click on the menu, and then use typeahead to select the desired item, ie actions:

Click on popup menu
Insert Text by Typing "Menu Name%Return%"

The tricky part is clicking on the menu. First, make sure you have paused long enough to allow the window to come to the front and the screen to be stable, and then you can need to click on the popup. You can click in one of these ways:

  • if the window has keyboard focus, then you can click relative to the window, and if the popup menu is in a fixed location, then that may be a reliable solution.
  • click relative to the found image. If the popup menu always defaults to the same thing, then you can use the popup menu as the image. Otherwise, you need to click relative to something nearby that is consistent (like some label text).

To click relative to an image, you use the Mouse Click action, configure it to be relative to a found image, and take a screenshot of the desired area of the screen using Command-Control-Shift-4, and paste it into the image well on the action. The image has to be unique (which includes not being visible in the action if the image is small enough not to be shrunk in the image well) otherwise Keyboard Maestro will not know where to click. The Display option in the action will allow you to see where Keyboard Maestro is matching.

Thanks (to both of you) for the replies.

Chris, I wasn't aware that in System Prefs > Keyboard > Shortcuts > App Shortcuts, one can save a shortcut for a menu item that does NOT appear in the main menu bar at the top of the screen. That's an interesting revelation that may come in handy in other scenarios.

Peter, I wasn't aware that typeahead is available for pop-up menus, so that opens up numerous possibilities, as well. Thanks.

Peter, in many ways, I find that KM is more capable than QK, so I'm surprised to learn that KM doesn't currently have direct access to pop-up menus. I checked my QK macro (screenshot below) and confirmed that the method I used, at the time, was directly choosing the menu item by name (or, more accurately, a portion thereof, using the "contains" option).

Is it possible that KM might gain more direct access to pop-up-menu items in the future? :slight_smile:

Thanks again!

QK%20-%20Select%20email%20address

There is several places where Quickeys delves deeper into an application than Keyboard Maestro does. That is because Keyboard Maestro uses only public legitimate APIs, and Quickeys was not afraid of using private APIs and hacks to do its job. The result is that Keyboard Maestro versions 2 through 8 all run on High Sierra without issues (except for not knowing about new facilities or security restrictions).

Its possible. @ccstone shows a way that would work legitimately with Keyboard Maestro. But I'm not sure that way will work in general, and that is where the issues tend to lie. But I will look in to it again.

Makes complete sense. Thanks!

Support for finding buttons and AXShowMenu actions is done for the next version.

3 Likes

Thank you!

Great news!

:sunglasses: