Is there a way to get the sizes and positions of all open windows on the screen so that this information can then be easily used in a macro to restore the window sizes and positions?
I think it depends a little bit based on what you want. Your request could mean different things. For example, if I have an app with a window named "Smith" and then I close that window and open a new window later which also has the name "Smith," is that a new window or is that the same window? Either way you answer, there are issues to address. For example, what if two windows have the same name?
Another question you have to answer is do you want the "restore" to work after a reboot?
Another question you have to answer is which apps do you want this utility to work with? There are many apps that are not written with proper window support. So no solution can work with all apps.
And hopefully you aren't using macOS Spaces, which does not permit apps like KM to deal with properly.
If you really want to manage and position open windows on screen, Keyboard Maestro can do it, but there are any number of apps written to do just that. And while I love Keyboard Maestro, sometimes a more-precise tool can do one task better than the all-encompassing Keyboard Maestro can.
Search on "macOS window managers" (with the quotes), and you'll find a plethora of options.
-rob.
These days, the only window manager application that I know well is Moom. It is very flexible and certainly one can save and recall sets of window layouts (I do not currently use that functionality but maybe I should
).
Moom is made by Many Tricks, which @griffman is associated with, so he was being fair in not naming Moom (which I, as an independent customer, am happy to recommend) and in just commenting that there are a lot of window manager applications for Mac! Alternatives that might do what you want include Amethyst and Window Tidy.
I would just add that for me, it is not a case of KM or Moom for window management, since, with my latest revision of my workflows for such things, I use Moom controlled by KM (via Applescript). Anyway, the point about using a dedicated application for such tasks rather than (or in addition to) KM is not that KM cannot do the job, but that a good choice of dedicated application will save having to write complex macros and provide actions that are ready to go “out of the box”, already optimised and debugged for efficiency! Also, those applications may well provide options and tricks that one would not have imagined.
Hi, @kmNerd. You could loop through all of the open windows and use something like this...
Download: Front Window Characteristics via KM Tokens & AppleScript.kmmacros (6.8 KB)
Macro-Notes
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information
- macOS 26.1 (25B78)
- Keyboard Maestro v11.0.4
I agree with @griffman's point and like @kevinb use Moom. It's great! I've shared a macro that I use many time a day: Use Moom Layout Sets
Thanks, everyone! I just installed Moom, and so far I’m really liking it.
