Skip to content

Instantly share code, notes, and snippets.

@rithvikgv
Created February 26, 2012 13:51
Show Gist options
  • Save rithvikgv/1916910 to your computer and use it in GitHub Desktop.
Save rithvikgv/1916910 to your computer and use it in GitHub Desktop.
AppleScript to snap windows to the left à la Windows 7 Aero Snap
-- get Dock height
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_height to item 2 of dock_dimensions
end tell
-- get the new width and height for the window
tell application "Finder"
set desktop_dimensions to bounds of window of desktop
set new_width to (item 3 of desktop_dimensions) / 2
set new_height to (item 4 of desktop_dimensions) - dock_height
end tell
-- get active window
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
-- resize window
tell application frontApp
activate
set bounds of window 1 to {0, 0, new_width, new_height}
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment