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... ︎
Has anyone figured out a way to replicate the Windows “menu key” on a Mac using KM?.kmmacros (4.3 KB)