How do I resize all my windows when I switch displays?

Is there an app that will let me automatically resize all my open windows when I switch between working on my laptop screen and my external monitor?

I spend my time either working on an external monitor connected to my mbp or just my mbp. When I switch from monitor to laptop, all my fullscreen (the old definition) apps have windows that are bigger than my laptop resolution. I have to resize all of them, but then when I reconnect to the external monitor they are all smaller then I would like them.

I've tried moon, but have only been able to resize windows on a single space at a time, I typically have multiple applications in fullscreen mode (the old definition) open across multiple spaces.


There are endless ways to do this, so here are a few:

  • Before you unplug the external monitor open up the Displays Preference Pane in System Preferences and click on the "Gather Windows" button.

    [or if you already unplugged]

  • Hold the Option key down and choose "Arrange in Front" from the Window menu.

    [or]

  • Use the Option key and click the (+) at the top of any Finder window and it will resize them all automatically.


This Applescript script might also work:

tell application "Finder"
-- get desktop dimensions (dw = desktop width; dh = desktop height)
set db to bounds of window of desktop
set {dw, dh} to {item 3 of db, item 4 of db}
end tell

tell application "System Events"
repeat with proc in application processes
tell proc
repeat with win in windows
-- get window dimensions (w = width; h = height)
set {w, h} to size of win

-- get window postion (l = left of window; t = top of window)
set {l, t} to position of win

-- nh = new window height; nw = new window width
set {nh, nw} to {h, w}

-- window width is bigger than desktop size,
-- so set new window width to match the desktop
if (w > dw) then ¬
set nw to dw

-- window height is bigger than the desktop size (minus menu bar),
-- so set new window height to be desktop height - 22 pixels
if (h > dh - 22) then ¬
set nh to dh - 22

-- r = right coordinate of window; b = bottom coordinate of window
set {r, b} to {l + nw, t + nh}

-- nl = new left coordinate; nt = new top coordinate
set {nl, nt} to {l, t}

-- left coordinate is off screen, so set new left coordinate
-- to be 0 (at the left edge of the desktop)
if (l < 0) then ¬
set nl to 0

-- top coordinate is above bottom of menu bar (22 pixels tall),
-- so set new top coordinate to be 22
if (t < 22) then ¬
set nt to 22

-- right coordinate extends beyond desktop width,
-- so set new left coordinate to be desktop width - window width
if (r > dw) then ¬
set nl to dw - nw

-- bottom coordinate extends beyond desktop height,
-- so set new top coordinate to be desktop height - window height
if (b > dh) then ¬
set nt to dh - nh

-- if we have calculated a new top or left coordinate, reposition window
if (l ≠ nl or t ≠ nt) then ¬
set position of win to {nl, nt}

-- if we have calculated a new height or width, resize window
if (h ≠ nh or w ≠ nw) then ¬
set size of win to {nw, nh}
end repeat
end tell
end repeat
end tell

Of course there's also the paid alternative, which might include Stay, Divy, Arrange, etc.


You might give Stay a try. It lets you set window sizes/arrangements based on attached displays, and has Spaces support. I'm not sure if it has the exact behaviour you're looking for with Spaces (the FAQ is unclear), but it's probably worth checking the demo out at least.


I tinkered around with keyboard shortcuts for window behaviors. Mission control is the main reason I switched my daily driver to Mac from PC, but it takes a little customization to make it better. Here are some I made:

For all applications:

Move Window to Left Side of Screen: control-option-command-,

Move Window to Right Side of Screen: control-option-command-.

Zoom: control-option-command-/

Some apps function differently. For example, the Photos app would require a different command for "Zooming the window" because the "Zoom on photo" command confuses it. So I simply made it:

For Photos app:

Zoom: Z (function-Z)

Zoom All: control-option-command-/

To be honest, I haven't used an external display yet, but I hope this helps you! This works for me because I like to have an app "snap left" or "snap right" like in windows without going into full screen mode, since I like having the menu bar visible always. And using "zoom" makes it "full screen" without actually entering full screen mode.

(To add keyboard shortcuts, go to System Preferences > Keyboard > Shortcuts then click on the plus sign to add one.)