A user asked me a question about Moom…
Say I’ve resized a window to the dimensions I want. Is there a way to figure out what these are so I can create a resize action in Moom?
Basically, the user wants to save a window size as a custom action, to make it easy to reapply that action to any window. (If it were just one window in one app, you could use Moom’s Save Window Layout feature to save that layout for easy recall.)
There is a way to see this info in Moom, but it requires enabling our debug log and digging through a bunch of output. As an easier alternative, I was certain that AppleScript could do this; I fiddled a bit on my own, and did some web searching, which led me to this thorough post on StackExchange.
Using the very first bit of the first script there, I came up with this version:
tell application "System Events"
set appOfInterest to "Safari"
set windowXY to size of the first window of application process appOfInterest
display notification (item 1 of windowXY as text) & " x " & (item 2 of windowXY as text) with title "Frontmost window of " & appOfInterest & ":"
Run the above, assuming Safari is running and has an open window, and you’ll see this system notification:
Change Safari to whichever app you’re interested in, re-run the script, and you’ll have that app’s window dimensions. This script is incredibly basic (no error checking, hardcoded app), but it works1If you see a message about ScriptEditor needing Accessibility access, open System Preferences > Security & Privacy > Privacy, click on Accessibility in the left panel, click the lock icon to unlock the panel, click the plus sign to add an app, and navigate to Script Editor in Applications > Utilities, then click Open..
Of course, me being me, I decided I’d spend a couple hours making it more useful, even though I probably won’t use it all that often. So I modified it to work for whichever app is frontmost, and made it run from Keyboard Maestro. I then assigned it a gesture trigger with my mouse, so I can easily see any window’s dimensions with a simple mouse movement.