Browse the docs

Choose menu item by name

Finds a menu item anywhere in an app's menu bar by its name and chooses it, or lets you pick one from a list.

Choose menu item in app

Keyboard Maestro: SelectMenuByName

Details #

Searches the whole menu bar of an app, submenus included, for an item whose title matches text, and chooses it. You do not need to know which menu it lives in. When you do know the path, Choose menu item is more exact.

The match tries, in order: the exact title, a title that starts with the text, then a title that contains it. Case, surrounding space and "..." versus "…" are ignored. Only enabled items are chosen. The search goes up to six menu levels deep.

If text is empty, the step lists every enabled item as "File ▸ Export…" and asks you to pick one.

Parameters #

ParameterTypeRequiredValuesWhat it does
apptextThe app whose menu bar to search. Without it, the front app.
texttextThe menu item's name, or part of it. A whole path such as "File ▸ Export as PDF…" names exactly that item. Empty shows a list to pick from.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Choose "Save" by name
Do
  1. Choose the menu item “Save”
  2. Show “Menu item chosen”
Open in Switchboard to try it

Gotchas #

  • A partial name picks the first match in menu order, which may not be the one you meant. Use the full title when several items share a start.

  • An item that is greyed out fails with "X is greyed out. It may need a document open or something selected first."

  • When nothing matches, the failure reads "No menu item called "X"." with a list of titles found and a "Did you mean" suggestion.

  • Fails with "the app has no menu items to choose from" if the list is empty. If you dismiss the list, "cancelled by you".

  • Needs Accessibility permission. A dry run only simulates this step; it searches no menus and chooses nothing.

  • The list for an empty text has the usual 10 second step limit. Set a longer timeout on the step if you need more time to choose.

In the palette #

Press ⌥Space in any app and type part of a menu command, such as "export" in Safari. Rows under "Menu items" read "File ▸ Export as PDF…" with the app's name under them, at most five. ⏎ chooses the item, the same way this step does. ⌘⏎ makes a macro for it ("Safari: Export as PDF…", with a menuByName step, run only while that app is in front) and opens it with the hotkey recorder listening, so "I keep doing this" becomes a hotkey. Turn the rows off in Settings › Palette.

The output holds the menu path that was chosen, such as "File ▸ Save".

See also #

Choose menu item, Press button by name, Press keys