因为 AirPods 老是连着连着就掉了,恶心坏了

注意:
1. 系统需要是 Ventura,Monterey 运行不了,因为设置界面改了
2. 可以把脚本放进快捷指令,设置快捷键运行

代码如下

# 打开系统设置
activate application "System Settings"
tell application "System Events"
	tell process "System Settings"
		tell menu bar 1
			delay 1
			# 如果是中文系统请把这里改成 “声音”
			click menu item "Sound" of menu 1 of menu bar item 5
		end tell
		delay 0.5
		if radio button 1 of tab group 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1 is not selected then
			click radio button 1 of tab group 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
		end if
		delay 0.5
        # 因为只有两个输出设备,所以 row2,具体请自己写
		select row 2 of table 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
        # 设置音量为 40% 注释掉了 可写可不写
        # set volume 4
	end tell
end tell
delay 1
# 退出系统设置
quit "System Settings"