I have a macro that opens a context menu (by right clicking the mouse) and then typing the appropriate command and pressing Return. It works just fine. However, now I want it to open the SAME context menu (by once again right clicking) and selecting another option (the cursor position has NOT changed). But what actually happens is that the second time of right-clicking (magenta in the attached sample macro) the context menu appears and disappears in the blink of an eye and before the insert text action can happen. I tried disabling subsequent actions so that in theory the macro should end with the context menu showing... but it flashes away. (I tried pauses before the second mouse action to no avail)
I have tried this in my app (Family Tree Maker) and also in Numbers, Pages and Finder and the same issue seems to be universal. So I have a three part question... Am I doing something silly or if Not Has anyone else seen similar and finally any thoughts on what else I could try. (I have thought of running the macro twice with just one menu call but that feels inelegant)
You really need one after both "Move and Right Click" actions, to give the menu time to populate. You probably need one after each "Keystroke: Return" as well. In my testing, I didn't need one between "Insert" and "Keystroke".
Any time you are having trouble driving the UI, start by adding lots of pauses so a) you can see what's happening, and b) your macro doesn't outpace the UI.
Thanks both. I had in fact tried various pauses, but not in the right places and too short ... 2 seconds seems to do the trick. Next time I'll be less hasty... thanks both
Okay. This is why the first test of a Pause action should be ridiculously long, then you can narrow the Pause until it reaches its minimum. Even better, it's usually possible to place a conditional pause that waits until it sees that it's ready to go to the next step. So for example, in this case you could use the OCR action to check if the "Copy" string appears in the area near the mouse, and not move to the next statement until "Copy" is visible. This should be very quick if written correctly. But for many people this kind of robustness is overkill.
Sage advice indeed, which I'll do my best to heed in future. I have in fact been systematically changing static pauses to conditional wherever I can but the OCR trick never occurred to me... so thanks for that tip too