雖然在Mac中使用(Option+鼠標左鍵)點擊聲音圖標就能選擇聲音輸出,但是依然不夠方便。

下文將描述通過Spotlight切換聲音輸出源的方法。(本文的方法只支持最多2種聲音輸出源的切換)
首先當然是寫一個Apple Script,用來一鍵切換聲音輸出源,腳本如下:
try
? ? tell application "System Preferences"
? ? ? ? reveal anchor "output" of pane id "com.apple.preference.sound"
? ? end tell
? ? tell application "System Events" to tell process "System Preferences"
? ? ? ? tell table 1 of scroll area 1 of tab group 1 of window 1
? ? ? ? ? ? set selected_row to (first UI element whose selected is false)
? ? ? ? ? ? set currentOutput to value of text field 1 of selected_row as text
? ? ? ? ? ? select (row 1 where value of text field 1 is currentOutput)
? ? ? ? end tell
? ? end tell
? ? quit application "System Preferences"
end try
打開腳本編輯器,粘貼并運行,確保腳本能正常執(zhí)行。

導出腳本為應(yīng)用程序,并取一個好記且辨識度高的文件名,如“MyHouseExploded”

在Spotlight中修改聲音輸出源
