Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muthuishere/06038d42567d82c1a83e4bc9e88dad94 to your computer and use it in GitHub Desktop.
Save muthuishere/06038d42567d82c1a83e4bc9e88dad94 to your computer and use it in GitHub Desktop.
Applescript to move all the windows from in accessible leftmost monitor to accesible external monitor
-- Change the windows which should not be moved
set MAXIMUM_X_VALUE to 1900
set positiontobemove to 0
tell application "System Events"
set allProcesses to a reference to (every process whose background only is false)
set windowList to {}
repeat with thisProcess in allProcesses
set processWindows to every window of thisProcess
repeat with thisWindow in processWindows
set windowName to name of thisWindow
set windowPosition to position of thisWindow
set windowSize to size of thisWindow
set xPos to item 1 of windowPosition
set windowWidth to item 1 of windowSize
if xPos + windowWidth > MAXIMUM_X_VALUE then
set monitoraction to "Can Be Moved"
set position of thisWindow to {positiontobemove, 0}
set windowPosition to position of thisWindow
else
set monitoraction to ""
end if
set thisWindowInfo to {name:windowName, position:windowPosition, size:windowSize, action:monitoraction, positiontobemove:positiontobemove}
set end of windowList to thisWindowInfo
end repeat
end repeat
return windowList
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment