I was trying to add a Menu Item to my custom Floating Menu for iTerm2; that calls the Trigger Context Menu Item action; which I want to use to select a right-click menu item in iTerm2; but instead it seems to be triggering the right-click context menu of the my custom Floating Menu itself.
The description of Trigger Context Menu Item says:
Using this you can trigger context-menu items or sub-items for the current mouse-cursor position in any application.
Since we're clicking the Menu Item to trigger it, that's obviously why it's calling the context-menu of the Floating Menu.
It would be cool if we were able to specify the window we want to trigger the context menu item on as part of the action; though I guess it might be too complex to support all possible cases there.
I was thinking I could use the Move Mouse To Position action before calling Trigger Context Menu Item; but then I wasn't sure how to get the coordinates to move it to.
It seems we can't name an application in the coordinates configuration:
I then figured that maybe I could use Assign/Set Value for Variable (as I wanted to use a unique name so there was no risk of conflicting with other triggers that might save/restore the mouse position) to store the mouse position within iTerm2 before I trigger showing my Floating Menu, and then use that to move the mouse later; but it didn't seem as though I could set the variable to the value of an existing variable (or if it is, the UI didn't make it obvious as to how I could do that with a button/dropdown/similar):
So as a fallback, I figured I can use Save Current Mouse Position / Restore Saved Mouse Position, and just hope that that doesn't conflict with anything else that uses it (It might be cool if we were able to optionally specify a custom name/ID for the mouse position to be saved/restored from to reduce the possibility of conflicts):
This still seemed to trigger the context-menu on the Floating Menu, so I then also added a Wait For Condition To Become True as well, configured to wait till the custom menu was no longer visible (
visible_floating_menu_identifiers NOT contains iTerm2):
This finally seemed to trigger the context-menu on iTerm2 rather than the Floating Menu, but then it didn't seem to actually select the Swap With Session item on that menu that I was trying to trigger.
At this stage i'm not really sure if where I got to is not working because of a bug, or something I have done wrong; and also not sure if there is (or could be) an easier way to achieve some of the things I was trying along the way / as a final solution.