Resizing macOS app windows for 16:9 screen capture

I frequently need to capture a window of some Mac app for a recording (usually for my YouTube channel), and I've used a little AppleScript I wrote years ago for the purpose.

Somehow, that script (which I saved as a 'one shot' App (.app extension) that just runs then quits) got deleted off my Script Editor folder in my iCloud Drive, so I had to re-create it.

Luckily, the syntax for this operation is dead simple:

tell application "Safari"
    set bounds of front window to {0, 50, 1280, 770}
end tell

You can adjust the {X, Y, width, height} parameters accordingly—note that the width and height seem to be additive to the X/Y. So I use 770 instead of 720 for the height (720 + 50).

In Script Editor, save the file as a .app, with the option to keep it running unchecked. Now, whenever you want a window sized perfectly for capture, just press Command + Spacebar, then type in the name of the Script/App you saved, and hit enter. The top-most window in Safari will scale to exactly 720p resolution.

I have similar scripts set up for Terminal and other apps I frequently capture, so I just hit Command + Spacebar, type the name of the app I need to resize, and press enter.

I also had an earlier post describing resizing Terminal here, but that method required a bit more AppleScript that's really not necessary for my use case.

Comments

I believe it’s additive because you’re specifying two pairs of XY coordinates for the top left and bottom right corners of the window. So 0,50 for top left and 1280,770 for bottom right in your case.

CoreGraphics does this so I presume AppKit/AppleScript does too.

Very nice solution to a simple problem.

I use a piece of software called SizeUp (https://www.irradiatedsoftware.com/sizeup/) to do that as well as move/manage windows on a multi-monitor setup. It is $13, but I'm happy to pay since it's a perpetual license. I've been using it for years and never had issues with MacOS updates.

There also appears to be a FOSS solution called Rectangle (https://github.com/rxhanson/Rectangle) that looks really good. Not sure it supports setting the window to a specific size, but lots of other great features to support moving/managing windows on a multi-monitor setup.

My absolute favorite though is being able to split documents side by side on a single monitor in 2 keystrokes. Absolute game changer when you're reviewing documentation/code/whatever.

SizeUp can resize a window to a specified size. Rectangle can't! I have been searching for something like that for so long… Thanks for sharing, Kyle!

I spent far too long looking for solutions in JavaScript that would resize a Safari window. Eventually found the right combination of search words that led me here, and...well...thank you, my man.

OMG, this is fabulous! I'd never used AppleScript before. Thank you!!!