虽然在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
打开脚本编辑器,粘贴并运行,确保脚本能正常执行。
导出脚本为应用程序,并取一个好记且辨识度高的文件名,如“MyHouseExploded”
在Spotlight中修改声音输出源