Fuzzy menu item name in select menu action

Is it possible to get fuzzy naming in select menu action?

I have several macros that use menu as part of their workflow. For examples one of them opens selected file in ForkLift with MacVim. I use main menu File > Open With which has a list of applications that is built dynamically based on selection. But the menu item corresponding with particular application is not always consistently named; sometimes it’s called “MacVim”, sometimes “MacVim (default)” and sometimes “MacVim 8.0.nnnn”. First two options are easy to handle, but last one has different number with each new version so I have to constantly update the macro. Can I specify the name of the menu item as regex, or otherwise use “fuzzy” naming?

As far as I know Keyboard Maestro doesn't support fuzzy naming, but it does support regex, and can also use APPLICATION as a catch-all for most front application names. You can see more info here: https://wiki.keyboardmaestro.com/action/Select_or_Show_a_Menu_Item

In your case, I think regex naming might be the way to go. I don't have ForkLift or MacVim, so I can't test this myself, but theoretically something like this should work:

(As explained in the wiki link, the ^ at the start is what lets you use regex in menu items)


Oh, cool, wasn’t aware of that, but it’s exactly what I need!

FYI if regex matching doesn't seem to work at all, it could be a subtle problem with the type of "caret" character that your Mac keyboard inserts when you press Shift-6.

Say you want to match a menu item like "Move to Folder1 again" knowing that it won't always be Folder1 in the middle.

This works: ^Move.*again

This does not work: ˆMove.*again

You want the ^ symbol -- not the very similar looking ˆ symbol

The one that works is what macOS considers:
Unicode: U+005E, UTF-8: 5E

You'll get that with the Mac keyboard layout set to U.S. or ABC Extended.

But for some reason, mine happened to be set to "U.S. International - PC". In that case, when you press Shift-6, you get a slightly different character that won't work for regex purposes:
Unicode: U+02C6, UTF-8: CB 86

This wikipedia article sort of explains the ASCII history differences: https://en.wikipedia.org/wiki/Caret

1 Like

On the US International PC layout you have to press 6 followed by Space.

This is because on that layout 6 works as a dead key (with the same output as I):

⇧6 followed by one of a,e,i,o,u produces â,ê,î,ô,û. But followed by a Space it gives you the big standalone Circumflex ^. (= The same as simply ⇧6 on the normal US layout.)

1 Like

Oh good point Tom. That makes sense. I've set my keyboard back to regular U.S., but certainly for people who do want to use International, your suggestion is a much better approach.