I want to create a Macro that moves my Zoom window to another monitor. Then, sometime later, I want to move it back to the original location. I want this to act as a toggle.
My problem is that I don't think the variables are persisting between toogles.
This has a built in function for undoing a window and moving it back to the original location.
In your macro you are setting the OriginalPosition regardless everytime so when you move the front window you are telling it to make OriginalPosition to where you current location is so
It's more of something you would just use to move the window and then just use the undo to move it back assuming you wouldn't be using the macros to move several other windows while you are doing your presentation.
For what it is worth at least for me it is helpful if the macro is also uploaded to quickly build and test where things have issues. I am not as good as some of the other users on here that just spot something and can see right away what is wrong. I built it the same way you had it so you didn't have to change anything so hopefully that gives you what you need above.
I’d probably recommend that you look at my macros for inspiration, rather than trying to use them directly.
Even though I designed my macros/sub-routines to be easily modified, they are all designed to work together in a unified manner. So, unless you want to mostly use the Cycling Window Manager as-is but with a bit of customization, it would be better to make your own macro for your particular purpose.
Basically, if you try to run my subroutine out of context, there could be a bunch of headaches.
Thanks for chiming in, I was kind of thinking that might be the case since things are stored for what you are using them for and allowing you to undo based on when yours runs. Hopefully @michaelhyatt what I posted above gives you what you need.
It'll help if you find out which screen the window is on and decide what to do based on that. As pseudo-code:
if window is on main screen
then
save window's frame to global_variable
move and resize window to teleprompter
else
use global_variable to move and resize window on main screen
end
Give it a go with the above as your starting point and see how you get on.
Or...
I think (I haven't tested it) that your problem is the last action -- you are setting the front window position but you previously saved the window's frame.
All of the different macros communicate with each other to keep track of common state information. So, if one wants that feature, one should start with the Cycling Window Manager and tweak it to their desires. But, if one doesn’t want/need the interconnected state tracking, then it would be better to build something separately.
Okay, I tried your macro, but the last action (under "Otherwise execute the following actions") is not moving the window back to it's original position. Should I be using another action?
Strange I tried it but my guess is you have moved focus back to the window that is in front of you rather than the presenation window. Try it in the Finder and hopfully you'll see it move the window back to where it was. I tested it on my machine and it worked fine as long as the same window is focused.
I did try it in Zoom with one window but there also could be things happening with the presentation window where that doesn't have any sort of focus.
So weird. I installed your version of the macro and it's still not moving the window back to it's original position. I clicked on the same window after I moved it to my teleprompter, just to make sure it had the focus.
That is odd, so it is moving it to the window above your display but just not moving it back. Did it work with a Finder window so you can at least narrow it down to Zoom?
I wonder if it has something to do with windows being stacked on top of each other. That always seems to cause issues on a Mac through the years. I will stack my displays and get back with you. I put my monitors side by side even when they are stacked on top of each other most of the time for those reasons.
The first action saves the window's rectangle: left,top,width,height
The window is then moved, its rectangle becoming a,b,c,d
The last action attempts to reset the window to its original state using the saved rectangle -- but it is only setting the window position, the x,y coordinates of the top-left corner
So that final action is trying to set a pair of values to a quartet:
set window's x,y to left,top,width,height
...and the best result you can hope for is the window frame is left,top,c,d -- but it might set it to something else entirely, or simply error out.
@michaelhyatt -- if you don't want to rebuild the macro from scratch following my pseudo-code above, try just changing the last action of yours so it sets "the front window frame", not its position: