Using Mac’s Automator app you can resize the current window by creating a new “Quick Action”. Once created this action will appear in your services list for every application.
Here is the AppleScript to set a window to the size 720p (1280px by 720px). However, some applications like PhpStorm do not have window bounds and will not work.
tell application "System Events"
set theApp to get name of first process whose frontmost is true
end tell
tell application theApp
set bounds of front window to {0, 0, 1280, 720}
end tell
2 thoughts on “Resize Any Mac App to a Precise Size”
REFINED THE SCRIPT EVEN FURTHER:
1) Remembers last used value cross sessions (persists into text file and calls values when script starts)
2) Now supports mathematical expressions. I simply evaluate them via do shell script and utilizing bc (basic calculator).
tell application “System Events”
set theApp to get name of first process whose frontmost is true
end tell
tell application theApp
set lastInput to (do shell script “cat ~/Library/Application\\ Support/ResizeCurrentWindow/dimensions.txt”)
set myReturn to display dialog “Resize current window to X x Y pixels
– X and Y can each be a mathematical expression” default answer lastInput
set myText to text returned of myReturn
do shell script “echo ” & myText & ” > ~/Library/Application\\ Support/ResizeCurrentWindow/dimensions.txt”
set AppleScript’s text item delimiters to {” “}
set parts to (every text item in myText) as list
set AppleScript’s text item delimiters to “”
set xxx to item 1 of parts
set yyy to item 2 of parts
set xxxEval to do shell script “echo ‘scale=1;” & (xxx) & “‘ | bc”
set yyyEval to do shell script “echo ‘scale=1;” & (yyy) & “‘ | bc”
set {x1, y1, x2, y2} to the bounds of front window
set the bounds of the front window to {x1, y1, x1 + xxxEval, y1 + yyyEval}
end tell
Hey Stefan,
Thanks for sharing this. I have not tested your code yet, but maybe someone will find this helpful if their needs require it.