Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Created July 19, 2012 02:09
Show Gist options
  • Save metalrufflez/3140318 to your computer and use it in GitHub Desktop.
Save metalrufflez/3140318 to your computer and use it in GitHub Desktop.
Rotate external display (OSX Lion only)
tell application "System Events"
if process "System Preferences" exists then
tell application "System Preferences"
quit
end tell
end if
set t to a reference to every desktop
set targetdisplay to display name of item 1 of t
tell application "System Preferences"
activate
tell application "System Events"
key down command
key down option
end tell
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
tell application "System Events"
key up command
key up option
end tell
end tell
tell window targetdisplay of process "System Preferences"
set actualrotation to value of pop up button 1 of group 1 of tab group 1
if actualrotation is equal to "Standard" then
click pop up button 1 of group 1 of tab group 1
click menu item "90°" of menu of pop up button 1 of group 1 of tab group 1
delay 5
click button "Confirm" of sheet 1
else
click pop up button 1 of group 1 of tab group 1
click menu item "Standard" of menu of pop up button 1 of group 1 of tab group 1
end if
end tell
end tell
tell application "System Preferences"
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment