I've made macros to set up several "workspaces" that put 3-4 apps in specific screen positions. Sometimes I want to enlarge and center one of them for some concentrated work. I searched the macros library and found nothing about returning a window to its previous position.
Is that possible with Keyboard Maestro? It seems one could add a step in each macro that moves a window that puts the current position in a variable that the "return" macro could access. Am I on the right track?
I'd rather avoid running the original workspace macro that hides all, then positions everything on the screen. Just too much jumping around on the screen when I just want to move one window.!
You’re on the right track. Prior to moving/resizing a window, set a variable to its current position and size. Then, use that variable to reset the window to its original state.
There's a lot of different ways to handle this, but let me suggest this method first:
Put the code that positions each app's window into a separate macro. Your main macro can launch one application (if it needs to), then call the "positioning" macro. Then launch another app, and call its positioning macro. Etc.
For each positioning macro, put it in a group that's only "available" for that application.
And give the macro a hotkey trigger. That allows you to restore your preferred position with a simple keypress. You can make the hotkey the same for all the positioning macros, since they're only active when their application is active.
If that isn't going to work for you, let me know.
Another option, which I use all the time, is BetterSnapTool. You can set up snap areas for each application (or multiple apps, or all apps), and even add hotkeys for them.
I'm not sure if this would fit into your workflow, but it's something to think about.
I'm using Moom to position the windows, rather than Keyboard Maestro macros. However, I use KM to send the Moom positioning shortcuts. Each workspace KM macro:
Hides all windows
Activates the desired apps and sets their starting views (sidebars, OmniFocus perspectives, BusyCal week view, etc.)
Sends Moom the shortcut for the desired "Arrange windows" setup. (You create by arranging windows, then taking a snapshot. No need to do pixel calculations, and easy to adjust and reshoot!)
To temporarily move a window out of its workspace position, I use Moom's basic "Move and zoom" functions I've mapped to keyboard shortcuts. (left 1/3, top right 1/4, etc.)
Moom has a "revert to original dimensions" function, but it returns the window to the last mouse-dragged position, not the last place Moom put it. So it ignores my automated "Move and zoom" positioning. I had the idea to start each "move" macro with moving the window 1px to the left, and having my "previous position" macro move it 1px to the right after doing Moom's "revert" function, but that may be unnecessary if I can do something simpler with variables.
Thanks for the explanation. I think your idea is a good one - moving the window 1 pixel. I'm thinking you could probably move it back 1 pixel right after that, so the "revert" position is where you initially had it.
Worked it out by using my Keyboard Maestro macros to type keystrokes that Moom responds to my moving the window, and starting each macro with a "Set Variable" action that stores the current window position. My "Revert to last position" macro just uses that variable to set the front window position.