Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created May 11, 2018 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/4ee4977c6c7024284ac36faeb564825f to your computer and use it in GitHub Desktop.
Save OKsign/4ee4977c6c7024284ac36faeb564825f to your computer and use it in GitHub Desktop.
-- user input
set Output to {"item1", "item2"}
set Input to {"item1", "item2"}
-- end of user input
set userList to {"(( OUTPUT ))"}
repeat with i from 1 to count Output
set itemPre to item i of Output & " ."
delay 0.02
copy itemPre to the end of userList
end repeat
copy "(( INPUT ))" to the end of userList
repeat with i from 1 to count Input
set itemPre to item i of Input & " ."
delay 0.02
copy itemPre to the end of userList
end repeat
delay 0.2
set userListChoose to (choose from list userList with prompt "Output/Input" with title "Script 7" with multiple selections allowed)
if userListChoose is not false then
try
delay 0.02
repeat with i in userListChoose
if i ends with " ." then
set myOutput to i
exit repeat
end if
end repeat
repeat with i in userListChoose
if i ends with " ." then
set myInput to i
exit repeat
end if
end repeat
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Preferences"
repeat 300 times
set winName to get name of front window
if winName is "Sound" then
exit repeat
end if
end repeat
end tell
-- output
tell application "System Events"
tell process "System Preferences"
tell tab group 1 of window "Sound"
click radio button "Output"
delay 1
set selected of row 1 of table 1 of scroll area 1 to true
delay 1
tell application "System Events"
keystroke "f" using command down
delay 0.7
repeat 2 times
key code 48
delay 0.07
end repeat
keystroke myOutput
delay 1
end tell
end tell
end tell
end tell
-- end output
-- input
tell application "System Events"
tell process "System Preferences"
tell tab group 1 of window "Sound"
click radio button "Input"
delay 1
set selected of row 1 of table 1 of scroll area 1 to true
delay 1
tell application "System Events"
keystroke "f" using command down
delay 0.7
repeat 2 times
key code 48
delay 0.07
end repeat
keystroke myInput
end tell
end tell
end tell
end tell
-- end input
delay 2
tell application "System Preferences"
quit
end tell
delay 1
tell application "System Events"
display notification "Done!" with title "Script 7"
end tell
end try
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment