Has Anyone Figured Out a Way to Replicate the Windows "Menu Key" on a Mac Using KM?

For those unfamiliar with the Windows menu key...

It's basically the equivalent of right-clicking whatever is currently selected on your computer. (But the solution isn't as simple as triggering a right click, since what you currently have selected, e.g. a file in Finder, may be nowhere near your cursor.)

1 Like

I would be very interested in a solution to this too. I have some steps in macros that involve calling up the context menu - but as you say, it is not enough to have the item selected - the mouse cursor must be over the item too (and it's easy to forget to move the mouse cursor over the item before running the macro).

I've never found a way on a Mac to bring up the content menu without the cursor actually being over the item. But maybe some of the Gurus on this forum have been able to achieve this? Maybe there is a way to move the cursor over a selected item automatically?

1 Like

Exactly! That's the key step. Figuring out a way to automate moving the mouse cursor on top of the file or text or whatever is currently selected.

Does remapping the Caps Lock key - with eg Karabiner Elements - get you where you want to go? (You would remap it to an improbable key combination such as Ctrl+Alt+Shift+Cmd+ and use that as a hot key trigger in Keyboard Maestro.)

1 Like

I'm not sure I follow how this would replicate the functionality of the Windows "menu" key, as described. Maybe I'm missing something?

Yes. The key itself is not that important (if I'm following this correctly). It's the function that key performs (namely, activating a context menu for a selected item, without the cursor having to be hovering over that item) that you (and now I) are looking for a possilbe solution to.

A Google search didn't come up with any solutions so, this might just not be possible.

2 Likes

As i had a "water" spillage, my laptop does not respond well to left or right clicks, so I have hotkey combos to simulate them. Anyway, whilst I understand the question, the whole point about KM is that you go to do exacly what you want, and therefore the functionality of the windows "menu/context" menu is superfluous, so I feel this effort to replicate it is misguided :frowning:

1 Like

It's possible, at least to some extent, but not simple, using AppleScript and GUI scripting. The script below (triggered by KM or some other hotkey utility) will do the trick in the Finder.Right_Click.scpt.zip (8.0 KB)

1 Like

Great. I will try out. Thank you.

1 Like

Thank you @eurobubba that AppleScript works perfectly for the Finder. Here it is in a Keyboard Maestro Macro.

To explain again the purpose of this whole exercise: This brings up the right-click Context Menu for a selected item in the Finder without the mouse cursor/pointer having to be hovering over that item.

From that point a Keyboard Maestro Macro can use the arrow keys to navigate that menu or Keyboard Maestro can type the first few letters of an item's name. And then Keyboard Maestro can emulate the press of "Return" to execute that item.

I can see where you are coming from @jonathonl but some items are only available from the Context Menu (ie they are not in the normal menus that Keyboard Maestro can easily access). This is why being able to invoke the Context Menu as part of a Keyboard Maestro workflow when a certain item is selected is so useful. And the key point here is that the mouse cursor doesn't have to be hovering over the item - it just has to be highlighted, i.e. selected. Of course Keyboard Maestro can already emulate a right-click but that would only be of any use if the mouse pointer was in the exact right spot. There are lots of times when I select an item, move the mouse but would still like to have Keyboard Maestro invoke the Context Menu. None of this has anything to do with Windows other than the fact that Windows already has a dedicated hardware key to do exactly this and Macs don't.

Now, I wonder if it is possible to have an adapted AppleScript for other apps... :smiling_face:︎

Has anyone figured out a way to replicate the Windows “menu key” on a Mac using KM?.kmmacros (4.3 KB)

2 Likes

Thanks @eurobubba for solving this and thanks @Zabobon for confirming! I'm relatively new to KM and haven't yet set up an AppleScript as an action. Any quick guidance on how to do this? I'm excited to try it out. This is something I've been looking for almost for a decade!

BTW, @Zabobon, you bring up a good point that beyond the basic functionality, you can also create additional macros building on this, e.g. selecting specific menu items by typing the first few letters of a context menu item and pressing enter.

The example macro I uploaded already has the AppleScript as an Action. To make new Actions with AppleScript in them in future you can select the Execute/Execute an AppleScript Action. Then you simply paste the AppleScript text into the Action.

1 Like

Got it. So I'd simply copy and paste the AppleScript text from your example macro into the AppleScript action in the new macro I'm creating?

Or you could select the whole Action itself and copy and paste that into a new Macro (Actions can be copied and pasted into other Macros).

1 Like

@Zabobon @eurobubba One other question for you guys. My keyboard actually has a "menu" key, which you can see here...https://d.pr/i/p9472V. This would be perfect to use as the trigger for this action.

However, I can't seem to get KM to recognize this key. Do you guys have any suggestions? Here's some further background that might be relevant...

http://jornane.me/doc/code-dip-v2b/

Without access to the actual keyboard it is very hard to advise you what to do. But I would guess the trigger type you could try is the "USB Device Key Trigger".

It's also worth pointing out (as @eurobubba already has) that this AppleScript only works in the Finder. It doesn't do anything in any other App. So, assigning the physical key to it is not going to completely reproduce the normal function of that key.

image

That's odd, @Zabobon. My options are laid out a bit different, and I'm not seeing a "USB Device Key Trigger" option...

What version of Keyboard Maestro are you using? Current version is 9.0.5

Same! Here's a screenshot...

image

Ah. In that case I have no idea why the list of triggers should be different. Hopefully someone else on the Forum can explain :slight_smile:︎ - only difference I can see is that yours is a trial version. I'm not sure what if any limitations the trial version has as it is so long ago I bought it.