A hot key defined in an application can trigger a macro to execute. But, the menu corresponding to the hot key can be selected via a mouse click also, so the no hot key trigger is involved. Example: ⌘ Q is pressed, and I can intercept that, but I want a macro to execute either when ⌘ Q pressed, or when the Quit item is selected via a mouse click. Is this possible? How? There is no menu invocation trigger that I've been able to find.
There are people on this website who can answer your question better than me, but I'm going to try my best. They can correct me if I'm wrong. And if I'm wrong, I will apologize.
Some apps might have AppleScript support and may (in theory) permit other software to intercept a user command. But you didn't tell us what the software you are using is, so we can't say in this case.
But more importantly... macOS sends "system events" for apps like KM to intercept when the user presses a key. That's the core idea behind how KM works. But, and I could be wrong, (and I really hope I am wrong) I don't think macOS sends an event to apps like KM to intercept when the user selects a menu item with the mouse (or even clicks on the mouse for any OTHER reason.) Thus, the limitation is with macOS, and KM only uses public APIs, so it can't (directly) achieve this.
HOWEVER there are (theoretical) ways to achieve what you want. For example, I once wanted to get KM to trigger on a mouse click, (which is similar to what you want to do) and all I had to do was use the software that comes with the mouse to REDEFINE the primary mouse button to an unused USB key, which KM could then trigger on. HOWEVER some software for some mice refuse to let you redefine the primary mouse button because the developers thought to themselves, "What idiot would want to redefine the primary mouse button?" And even if you do manage to redefine it, you still have to use the KM macro to figure out which menu command the user has the mouse positioned over.
You might be able to search the web for utilities which can help you out with this, but they would likely be using undocumented APIs, so they are vulnerable to breaking each time macOS gets updated.
P.S. This thread should be moved to the Questions forum, not the Macro Library forum.
@sleepy: Thank you for the thoughtful response. What you say is clear. I have the same point of view. I am still hoping to discover a workaround.
Nyet.
An application would have to be attachable, and the only such app I know of these days is BBEdit.
There used to be a 3rd party event-tap mechanism that was system-wide, but that died somewhere around High Sierra or Mojave.
-Chris
Sounds definitive. No AppleScript alternative? Even for Safari?
Attachability is a function of AppleScript, but an app has to be designed to be attachable.
No apps I know of today are attachable other than BBEdit.
Apple, the creator of AppleScript is very bad at making their own apps scriptable and/or improving same. It'd be helpful if they just fixed the bugs in Mail and the Finder, but those have been going for decades now...
Well, ironic, isn’t it. I used to be SVP for SW at Apple. (I worked at Apple “between Jobs”..). MacOS, languages, tools, networks, etc. and AppleScript used to report to me. I am well aware of the sorry state of affairs.
(2) Funny joke! (if you mean between the times he was CEO.)
(1) And wow.
Yes. It’s kind of an industry standard joke now. I joined Apple after Steve left and left Apple a month before he came back.
I've never seen a joke that exists only because one letter is capitalized. I wouldn't have got the joke if it had been spoken.
I'm wondering if I could do something similar with the word "polish."