Last active
October 21, 2022 18:17
-
-
Save seltzered/3b627104c8a7a39b863c to your computer and use it in GitHub Desktop.
Mac OSX Set Sound Output to Internal Speakers.applescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Script to set sound output - "Internal Speakers" hardcoded as I just keep multiple scripts for each output source (e.g. Internal Speakers, Airplay, bluetooth ) and use it with a quicklaunch app such as quicksilver. | |
-- Based off of Pierre L's answer in https://discussions.apple.com/thread/4629093?tstart=0 , which includes a selection dialog | |
set asrc to "Internal Speakers" | |
tell application "System Preferences" | |
reveal anchor "output" of pane id "com.apple.preference.sound" | |
activate | |
tell application "System Events" | |
tell process "System Preferences" | |
select (row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound" whose value of text field 1 is asrc) | |
end tell | |
end tell | |
quit | |
end tell |
This was very helpful using with Alfred! Thanks!
Hello, the above script doesn't work on apple script 2.8. It returns the following error: "Impossible to get window "Sound" of process "System Preference". (-1728). All of that using Monterey 12.1 and Applescript 2.8. In Big Sur Applescript 2.7 IT WORKS.
Regards
@ballacoilupi this tool works for me on 12.3.1: https://github.com/deweller/switchaudio-osx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, worked for me. :)