Created
April 15, 2020 12:55
-
-
Save cdbattags/9f003628563dc151109d1acb9f655d20 to your computer and use it in GitHub Desktop.
two AppleScripts: automating setting display orientation and setting audio output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set codec to "CODEC" | |
set headphones to "headphones" | |
tell application "System Preferences" to quit | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.sound" | |
reveal anchor "Output" of pane id "com.apple.preference.sound" | |
end tell | |
tell application "System Events" | |
tell application process "System Preferences" | |
repeat until exists tab group 1 of window "Sound" | |
end repeat | |
set theRows to every row of table 1 of scroll area 1 of tab group 1 of window "sound" | |
repeat with aRow in theRows | |
set stringRow to (value of text field 1 of aRow as text) | |
if stringRow contains codec or stringRow contains headphones then | |
set selected of aRow to true | |
exit repeat | |
end if | |
end repeat | |
end tell | |
end tell | |
tell application "System Preferences" to quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Preferences" | |
quit | |
delay 1 | |
launch | |
activate | |
tell application "System Events" | |
key down {option, command} | |
end tell | |
reveal pane id "com.apple.preference.displays" | |
tell application "System Events" | |
key up {option, command} | |
tell process "System Preferences" | |
tell window "S2719DGF (2)" | |
tell pop up button "Rotation:" of tab group 1 | |
if (value) contains "Standard" then | |
click | |
click menu item "270°" of menu 1 | |
my clickConfirmButton() | |
end if | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
on clickConfirmButton() | |
set wasClicked to false | |
repeat until wasClicked | |
delay 0.5 | |
tell application "System Events" | |
try | |
click button "Confirm" of sheet 1 of window 1 of application process "System Preferences" | |
set wasClicked to true | |
end try | |
end tell | |
end repeat | |
end clickConfirmButton |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment