Daniel Tull: Today I Learned

How to resize windows on macOS using AppleScript

Sunday, 19 April 2020

Needing to resize Xcode to be the right size for streaming, I found this link with some AppleScript to do that. Thanks Amit!

This Apple script will resize any program window to an exact size and the window is then moved to the center of your screen. Specify the program name, height and width below and run the script.

Written by Amit Agarwal on December 10, 2013

set theApp to "Xcode"
set appHeight to 1080
set appWidth to 1920

tell application "Finder"
	set screenResolution to bounds of window of desktop
end tell

set screenWidth to item 3 of screenResolution
set screenHeight to item 4 of screenResolution

tell application theApp
	set yAxis to (screenHeight - appHeight) / 2 as integer
	set xAxis to (screenWidth - appWidth) / 2 as integer
	set the bounds of the first window to { xAxis, yAxis, appWidth + xAxis, appHeight + yAxis }
end tell