Hello, forgive me if the answer to this is too obvious, but it's getting late! I want to perform a repeated action when the mouse is over a listbox. I want to perform a Right Click action, thereby bringing up a popup menu from which I can select a menu item. I just cannot get the Right Click action to work. I think the problem is with the positioning. If I could say "Position Mouse at Current Highlighted Control" and then "Right Click at Current Mouse Position" I would be okay, but there doesn't seem to be any obvious way of doing that.
After some research here, it seems that what I am trying to do is made difficult by limitations of macOS. The answer would seem to be to use the "Move and Click at Found Image" action, except for the fact the found image option here does not have the "Must be Unique" checkbox. I've now got to suss out how to use the separate "Find Image in Screen" action...
Okay, I've got a working solution. It's probably not the most elegant piece of code ever but it does the job, and the "Find Image" action will, I think, form the basis of a lot of my future macros.
Show Info.kmmacros (7.9 KB)
Your macro looks fine. When exporting a macro, use Share to the Keyboard Maestro Forum or Export Macros rather than Export Macro Library, which is really only any use for macros you want to import multiple times.
To nitpick your macro to help you for the future:
- The Pause should be after the Activate. After the Find Image is of no use, but you do want the screen to be “correct” when doing the Find Image.
- I would test the variable for is not empty rather than exists.
- You don't need the x & y variables, you can use “Arrows.x” and “Arrows.y - 60” directly in the Move & Click action.
- You might need a pause after the right click to allow the menu to appear.
That's great Peter. That's exactly the kind of "code critique" I'm after. Basic praise tempered with some constructive criticism
It looks like you did pretty well for a newbie.
And Peter gave you some good advice.
One item further:
Please export as macro rather than as library. Libraries are overly complicated for users to uninstall after testing your macro.
Keyboard Maestro will do the work for you:
Please also make certain that the macro(s) is/are selected and NOT actions in the Keyboard Maestro Editor – otherwise the output is in fact actions and not macros.
Actions get installed into the working macro, and this too has pitfalls for the user who is testing.
If I've failed to be clear please ask questions.
At the end of the day, its a good macro if it does what you want reliably (enough).
But there are often ways to make a macro shorter, easier, or more reliable.
I've implemented the recommended changes and edited the original post accordingly. Thanks to Peter and Chris for the help!