[AppleScript]Soundflowerとヘッドホンで出力を変更する(Finderスクリプト)
---処理を開始する前にシステム環境設定を起動しておく
tell application "System Preferences"
launch
set the current pane to pane id "com.apple.preference.sound"
end tell
tell application "Finder"
activate
---ダイアログを出す
display alert "サウンド出力の切り替え" buttons {"Soundflower", "ヘッドフォン", "キャンセル"} default button 1 cancel button 3 as informational
---button 1 Soundflowerの時の処理
if button returned of the result is "Soundflower" then
tell application "System Preferences"
launch
activate
set the current pane to pane id "com.apple.preference.sound"
tell application "System Events" to tell process "System Preferences"
set theTable to table 1 of scroll area 1 of tab group 1 of window 1
select (row 1 of theTable whose value of text field 1 is "Soundflower (2ch)")
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
end tell
---button 2 ヘッドフォンの時の処理
else if button returned of the result is "ヘッドフォン" then
tell application "System Preferences"
launch
activate
set the current pane to pane id "com.apple.preference.sound"
tell application "System Events" to tell process "System Preferences"
set theTable to table 1 of scroll area 1 of tab group 1 of window 1
select (row 1 of theTable whose value of text field 1 is "ヘッドフォン")
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
end tell
end if
end tell
| 固定リンク
「AppleScript」カテゴリの記事
- 濁音 半濁音 置換用レコード(2023.08.21)
- [AppleScript]キーノートの書類サイズを指定して作成(2022.01.09)
- [awk]行頭のスペースを削除する(subで置き換え)(2021.11.16)
- [SpotLight]選択範囲でSpotLight検索(2021.11.03)
- [AppleScript]リソースフォーク(カスタムアイコン)削除(2021.10.12)




[RSS]