Skip to content

Instantly share code, notes, and snippets.

@Holovin
Created October 7, 2021 21:12
Show Gist options
  • Save Holovin/8a4e85ce5903199d1bbd4a5dc876363a to your computer and use it in GitHub Desktop.
Save Holovin/8a4e85ce5903199d1bbd4a5dc876363a to your computer and use it in GitHub Desktop.
(*
Applescript to toggle between two sound outputs by Line number,
as they appear in the Sound Control Panel. Based on code by
Arthur Hammer http://apple.stackexchange.com/a/209434/85275
via https://apple.stackexchange.com/questions/217148/using-apple-script-to-manage-sound-output-selection
Модификация для русской MacOS
переменные output отсчитываются с единицы в окне
*)
set outputA to 2 -- change this to the actual 'line number' of your first desired output
set outputB to 9 -- change this to the actual 'line number' of your second desired output
--the rest of the script will use these vales as a switch
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
tell application process "System Preferences"
repeat until exists tab group 1 of window "Звук"
end repeat
tell tab group 1 of window "Звук"
click radio button "Выход"
if (selected of row outputA of table 1 of scroll area 1) then
set selected of row outputB of table 1 of scroll area 1 to true
else
set selected of row outputA of table 1 of scroll area 1 to true
end if
end tell
end tell
end tell
tell application "System Preferences" to quit
-- remove the comment '--' tag above to make the control panel quit afterwards, leave for testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment