Skip to content

Instantly share code, notes, and snippets.

@codeanpeace
Created January 2, 2019 00:06
Show Gist options
  • Save codeanpeace/1193f1485220d94b6d17bfb08b628de0 to your computer and use it in GitHub Desktop.
Save codeanpeace/1193f1485220d94b6d17bfb08b628de0 to your computer and use it in GitHub Desktop.
AppleScript that rotates display, toggling between landscape and portrait mode
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
end tell
tell application "System Events"
tell application process "System Preferences"
tell window "DELL U2414H"
delay 1
click pop up button 2 of tab group 1
delay 1
if (selected of menu item 4 of menu 1 of pop up button 2 of tab group 1) then
click menu item "Standard" of menu 1 of pop up button 2 of tab group 1
set rotationselected to "Landscape"
else
click menu item 4 of menu 1 of pop up button 2 of tab group 1
repeat until (exists sheet 1)
delay 1
end repeat
click UI element "Confirm" of sheet 1
set rotationselected to "Portrait"
end if
end tell
end tell
end tell
tell application "System Preferences"
quit
end tell
tell application "Growl"
set the allNotificationsList to {"Display Notification"}
set the enabledNotificationsList to {"Display Notification"}
register as application "Toggle Display Rotation" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
notify with name "Display Notification" title "Display Rotation" description rotationselected application name "Toggle Display Rotation"
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment