-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotateDisplay.applescript
43 lines (42 loc) · 1.27 KB
/
RotateDisplay.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
------------------------------------------------------------
-- Parameters
------------------------------------------------------------
set externalDisplay to "Acer CB281HK"
set landscapeKey to "Standard"
set portraitKey to "90"
------------------------------------------------------------
-- Toggle landscape/portrait view of external display
------------------------------------------------------------
tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
end tell
tell application "System Events"
tell process "System Preferences"
set frontmost to true
tell window externalDisplay
set _rotation to pop up button "Rotation:" of tab group 1
if value of _rotation contains landscapeKey then
log "Currently in landscape display."
click _rotation
keystroke portraitKey & return
set _confirmed to false
repeat until _confirmed
try
tell sheet 1
click button "Confirm"
set _confirmed to true
end tell
on error _errorMessage
log _errorMessage
delay 1
end try
end repeat
else
log "Currently in portrait display."
click _rotation
keystroke landscapeKey & return
end if
end tell
end tell
end tell
quit application "System Preferences"