r/applescript • u/TimmyGUNZ • Feb 02 '23
How to update this code for Ventura?
Hi there,
I have this small piece of ApplesScript that would allow me to easily switch my Mac's audio output from the built-in speakers over to a Bluetooth wireless receiver. Ever since Ventura was released, it no longer works.
Is there a simple update to the code that will make this work with Ventura? I'm still learning AS and I suspect that redesign of System Preferences is what broke this. I appreciate any help you can give.
tell application "System Settings"
reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
tell application "System Events" to tell process "System Preferences"
repeat until exists tab group 1 of window 1
end repeat
tell table 1 of scroll area 1 of tab group 1 of window 1
select (row 1 where value of text field 1 is "R-S202 Yamaha")
end tell
end tell
quit application "System Settings"
5
Upvotes
3
u/libcrypto Feb 02 '23
GUI scripting is very fragile, and this is GUI scripting. If you could find a way to do this without GUI scripting, that would make it more robust.
3
u/fuckinatodaso Feb 02 '23
Here's a script I use to automatically connect to my AirPods that still works after updating to Ventura (I'm currently on 13.2):
2
u/CO_Automation Feb 02 '23
There is a command line utility call switch audio
https://github.com/deweller/switchaudio-osx
Looks like it has what you need