How to set a window to an exact size and position on a Mac
Make a window exactly 1280 by 800 for a screenshot, a recording or a test. The built in presets, a one line script, and how to give it a keyboard shortcut.
Does macOS have preset window sizes?
Only relative ones. Window, Move & Resize offers halves, quarters, fill and centre, which depend on the screen. For an exact number of points you need a script.
How do I set an exact size with a script?
This sets the front window of the front app to 1280 by 800 points, with its top left corner at 100, 60:
osascript -e 'tell application "System Events"' -e 'tell (first process whose frontmost is true)' -e 'set position of window 1 to {100, 60}' -e 'set size of window 1 to {1280, 800}' -e 'end tell' -e 'end tell'The first time, macOS asks to let the app running it, such as Terminal, control your computer. Allow it in System Settings, Privacy & Security, Accessibility.
How do I run it with a key?
- Make a new Shortcut with the Run AppleScript action and paste the script below in place of its sample text.
- Give the Shortcut a keyboard shortcut. See run a Shortcut with a key.
- Switch to any window and press the key.
tell application "System Events"
tell (first process whose frontmost is true)
set position of window 1 to {100, 60}
set size of window 1 to {1280, 800}
end tell
end tellWhy does a window not reach the size I set?
Apps can set a minimum or maximum size, and some fixed size windows cannot be resized at all. A window manager may also move it straight back to its place.
Finder only: Finder window size. Recording at that size: record one window. Resizing by keyboard: resize windows with the keyboard.
Questions
How do I resize a window to an exact size on a Mac?
Use an AppleScript through System Events that sets the size of the front window, for example to 1280 by 800.
Can I save window sizes on a Mac?
Not built in. Save the script as a Shortcut with a key.
Why won't a window resize to the size I set?
The app may limit its window size, or the window may be fixed size.
Read next
- Guide
How to resize windows with the keyboard on a Mac
Resizing by dragging corners is slow. The keyboard shortcuts macOS has, the ones it lacks, and how to nudge widths and heights without touching the mouse.
Read › - Guide
How to record just one window on a Mac, with sound
Press Command Shift 5 and choose Record Selected Window. How to record a single window on a Mac, add system audio and clicks, and what older macOS offers.
Read › - Guide
How to make Finder windows open bigger on a Mac
Finder windows keep opening small, and there is no setting for a default size. The quickest ways to make a Finder window fill the screen, and keep it that way.
Read ›