Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Updated for Lion: Change Audio Output device' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Updated for Lion: Change Audio Output device
Authored by: idStar on Oct 29, '11 09:38:48AM

I've updated the original script to work with Lion, assuming English. This is a modification of the second script originally posted, that switches directly (without prompting) to the specified output audio device. In my example below, I have it switching to "Headphones". I have another script that is identical, but it switches to "Line Out". I saved these as applications and then just assigned hot-keys on my ergo keyboard to run these scripts. Very handy!



tell application "System Preferences" to activate
tell application "System Events"
get properties
tell process "System Preferences"
click menu item "Sound" of menu "View" of menu bar 1
delay 2
click radio button "Output" of tab group 1 of window "sound"
set theRows to every row of table 1 of scroll area 1 of
tab group 1 of window "sound"
set theOutputs to {} as list
repeat with aRow in theRows
if (value of text field 1 of aRow as text)
is equal to "Headphones" then
set selected of aRow to true
exit repeat
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit



[ Reply to This | # ]
Updated for Lion: Change Audio Output device
Authored by: nicklassa on Jan 08, '12 12:02:56PM

sorry for being such Mac noob but how did did you create the Automator script? I tried creating a new application, then run Apple Script by pasting in the script you posted. I ran a debug a couple of times and finally got it to complete without errors. Then I saved as an application as you said. Does not seem to work after editing my output source name. Am I missing something? TIA



[ Reply to This | # ]
Updated for Lion: Change Audio Output device
Authored by: idStar on Jan 09, '12 06:35:21AM

So, it looks like you got it working? Basically, I opened up the AppleScript editor app, pasted in the script originally posted, and then made my modifications. When you save it, you can save it various formats. By making it save as an "Application", I could target it from things like my Microsoft Keyboard's programmable keys app.

Now, as for changing the name, you must pick a name for the audio device exactly as it appears in your System Preferences. Alternatively, you can ALT-click on the sound icon in the menu bar to see the list of available sound devices you could target. If it's not in that list or you spell it wrong, then of course, you cannot use it.



[ Reply to This | # ]
Updated for Lion: Change Audio Output device
Authored by: nicklassa on Jan 10, '12 12:02:50PM

I ended up using AppleScript editior as you say. I gave up an automator. Its probably trying to make it easier, but the AppleScript editor is more simple in my opinion. Yeah I did have to double check the source name. And now it works!

Thanks



[ Reply to This | # ]