AppleScriptで音源変更
私は,iMacに2つの音出力をつけています.
一つは,BoseのM2.音を出して良い時間帯にスピーカから音を出力します.
もう一つは,DR.DAC2.音を出すと,他の部屋の皆さんに迷惑をかけてしまいかねない時間帯に使用します.このヘッドフォンアンプから,ヘッドフォンにつないでいます.
一つは,BoseのM2.音を出して良い時間帯にスピーカから音を出力します.
もう一つは,DR.DAC2.音を出すと,他の部屋の皆さんに迷惑をかけてしまいかねない時間帯に使用します.このヘッドフォンアンプから,ヘッドフォンにつないでいます.
この2つはそれぞれ時と場合に応じて使い分けているのですが,出力先をいちいち変更するのは面倒だなと,常々思っていました.同じようなことを考えている人がいるに違いないと思い,Google先生に聞いてみたところ,次のようなエントリを見つけました.
備忘録 : メモ:AppleScriptでGUIを操作する
備忘録 : メモ:AppleScriptでGUIを操作する
tell application "System Preferences" activate Set current pane to pane id "com.apple.preference.sound" end tell tell application "System Events" tell process "System Preferences" set awin to tab group 1 of window "サウンド" tell awin click radio button "出力" of awin tell scroll area 1 of awin tell table 1 of scroll area 1 of awin set t1 to table 1 of scroll area 1 of awin if row 1 is selected then select row 2 of t1 else select row 1 of t1 end if end tell end tell end tell end tell end tell tell application "System Preferences" quit end tell