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


Click here to return to the 'An AppleScript to change sound output device' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to change sound output device
Authored by: martin5211 on Feb 18, '08 04:36:22PM
This script is very useful... Thanks! I've added delay 1 before tell process "System Preferences" and removed the next delay, it worked better on my Mac. Also, I recommend a boolean check and an else statement to switch among two sound options automatically, try to insert the code below into the repeat loop and change the values between quotes:

if (value of text field 1 of aRow as text) 
	is equal to "Headphones" and 
	(selected of aRow as boolean) 
		is equal to false then
	set selected of aRow to true
	exit repeat
else if (value of text field 1 of aRow as text) 
	is equal to "Line Out" and 
	(selected of aRow as boolean) 
		is equal to false then
	set selected of aRow to true
	exit repeat
end if
With AppleScript Utility I can execute these scripts directly from menu bar too.

[ Reply to This | # ]
An AppleScript to change sound output device
Authored by: bcometa on Feb 18, '08 05:15:52PM

thanks for this update, if/then works great!

only one problem for me, which I've always had when using this script, hopefully someone who knows a little about applescript can help:

the script works if the last time i closed system preferences, I WAS IN THE OUTPUT TAB.

but if, for example, i went into sound and changed my input, then closed out of system prefs, then ran this script, it wouldn't work. it won't automatically switch over to the output tab if the last tab i used was input or sound effects.

is there anyway to tell the script "switch to the 'output' tab if not already there"?

thanks all!
brian cometa



[ Reply to This | # ]