Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spencersteers/4f2e7e55fe6accca5ec49cfd50852f43 to your computer and use it in GitHub Desktop.
Save spencersteers/4f2e7e55fe6accca5ec49cfd50852f43 to your computer and use it in GitHub Desktop.
Move Google Chrome windows to the right side of the screen.
use AppleScript version "2.4"
use framework "Foundation"
use framework "AppKit"
use scripting additions
set primaryScreenFrame to current application's NSScreen's screens()'s firstObject()'s frame()
set primaryScreenLeft to (item 1 of item 1 of primaryScreenFrame)
set primaryScreenRight to (primaryScreenLeft) + (item 1 of item 2 of primaryScreenFrame)
set primaryScreenTop to (item 2 of item 1 of primaryScreenFrame)
set primaryScreenBottom to (primaryScreenTop) + (item 2 of item 2 of primaryScreenFrame)
global primaryScreenLeft
global primaryScreenRight
global primaryScreenTop
global primaryScreenBottom
try
tell application "System Events" to tell application process "Google Chrome"
repeat with i from 1 to (count of windows)
set iWindow to window i
moveRight(iWindow) of me
end repeat
end tell
end try
on moveRight(iWindow)
using terms from application "System Events"
tell iWindow
set {winLeft, winTop} to position
set {winWidth, winHeight} to size
set position of iWindow to {primaryScreenRight * 0.42, 0}
set size of iWindow to {primaryScreenRight * 0.58, primaryScreenBottom}
end tell
end using terms from
end moveRight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment