Capture dimensions of existing window?

I know you can resize a window to certain dimensions, but is there a way to capture the dimensions of an existing window? Say I regularly want to resize a window size to a specific dimension—can I somehow get the size of the window other than trial and error?

For example, I want to get the size of the dictionary window below.

There's got to be a better way than what I'll document here (AppleScript maybe?), but I don't know it and this will at least give you something to get the information.

  1. With a window at a desired size and frontmost, Command-Control-Shift-4.

  2. Move the crosshair-style cursor over the window, press the Space bar (cursor switches to a camera), then click the mouse/trackpad on the desired window.

  3. Open Preview and select File > New From Clipboard (or just press Command-N).

  4. Use the Tools menu to select Adjust Size, then (if necessary) switch the pop-up menu to the right of the image dimensions to Pixels. You can now see the window size.

That gets the information, but there has got to be a more efficient way.

1 Like

%WindowSize% will give you a window's size in pixels, %WindowPosition% will give you its coordinates, and %WindowFrame% will give you both. See https://wiki.keyboardmaestro.com/token/Window_Tokens for more information.

4 Likes

Also the WINDOW function will return information about the window.

2 Likes