Automating System Preferences in Sound?

Hello All-
I am going out of my mind. I am trying to be able to toggle the output of my sound preferences back and forth between my Line Out and my M-Audio Firewire Solo. I do this multiple times a day. It would be great if I could hot key a way to do it or at least get the Automator on boeard. Any help?
Thank.
Paul

PowerMac G5, Mac OS X (10.4.3)

Posted on Jun 8, 2006 8:07 PM

Reply
8 replies

Jun 9, 2006 7:19 PM in response to Michael Henley

Thank you sir-
I looked at your suggestion of the Audio Midi and it is somewhere along the lines of my need, however I don't need to set the default but somehow be able to toggle Line Out and Firewire Solo Multichannel as audio output source. I do this multiple times a day, i.e. Firewire Solo is headphones only, and Line Out is, well, Line Out.
I almost had it working in the following applescript, but it won't click on the tab "Output" and then how do I do the if... then thing...? Any suggestions?
Many Thanks...


tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events" to tell the 1st tab group of the front window of process "System Preferences"
click button 2 of group 1 of window 1 of process "System Preferences"
if port is "Built-in Audio" then
set port to Firewire
else
set port to "Built-in Audio"
end if

end tell

Jun 18, 2006 2:56 PM in response to pmelley

Hi there,

if you haven't already got this, Prefab UI Browser, then I would suggest you get it. It makes scripting via the GUI a lot easier !

Below is a script which will select "Built in Audio" on My Mac...with GUI scripting you sometimes have to modify for each Mac.

You could save this as an Application, add it to your Dock and then just one click to select Built in Audio.

Then make a duplicate script but change the 'row' number to the Firewire Row..save again, then you have a one click for each...

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
tell process "System Preferences"
-- GUI Scripting statements:
click radio button "Input" of tab group 1 of window "Sound"

delay 1

--this is the first row on mine which is the built in audio
select row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound"

end tell
--I have put this delay in so that you can see it selct it !
delay 3
quit
end tell
</pre>

regards

Ric



PowerBook G4 1.67Ghz 17 100gb HD 1.5Gb RAM... Mac OS X (10.4.6) www.mac-help.com

Jun 18, 2006 11:26 PM in response to Ric Latham

I agree wholeheartedly with Ric about the UI Browser suggestion and in fact you can use it to start looking for attributes of those GUI items which can be used for developing your "if then thing".

I have also found that using the repeat loops instead of the delays tends to help with reducing some of the problems of transferring scripts to other computers. UI Browser was also invaluable in finding the attributes required for the repeat loops.

Here is a further development of the scripts that have already been provided. I have assumed that your two output options are on row 1 and row 2 of the list. If they are not then there are two options:
1) if they will always be found in the same location in the list then just change the row numbers in the "if then" clause;
2) if they are not always found in the same location because you have other output options which come and go then there will have to be some further checking. This is possible but I did not add it here because of the added complexity. Let me know if you need it.

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
tell process "System Preferences"
click radio button "Output" of tab group 1 of window "Sound"
repeat until (value of radio button "Output" of tab group 1 of window "Sound") is 1
end repeat
if (selected of row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound") is true then
select row 2 of table 1 of scroll area 1 of tab group 1 of window "Sound"
repeat until (selected of row 2 of table 1 of scroll area 1 of tab group 1 of window "Sound") is true
end repeat
else
select row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound"
repeat until (selected of row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound") is true
end repeat
end if
end tell
quit
end tell
</pre>

PowerBook 12" Mac OS X (10.4.6)

Jul 17, 2006 8:22 PM in response to Ric Latham

This really helped me! Thanks! I've installed Audio HiJack and Soundflower to enable "taping" Skype telephone interviews for my podcast. I run a high quality Mic through a mixed so I modified your script to select the Line Input and in Output, select the 2nd item (Soundflower 2ch). I made it an application and call it with iKey. The next part is using iKey to call the modified script:

tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
tell process "System Preferences"
-- GUI Scripting statements:
click radio button "Output" of tab group 1 of window "Sound"
delay 1
--this is the first row on mine which is the built in audio
select row 2 of table 1 of scroll area 1 of tab group 1 of window "Sound"

end tell

end tell


-------------end ----------------

after which I will set iKey to push the right buttons to click the soundflower and recording buttons in Audio Hijack and then open Skype.

One iKey stroke is now set up for rigging my Mac to make phone calls and tape them. This is cool! (I'm new at applescripting so thanks for the mentoring)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automating System Preferences in Sound?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.