Hi
Does anyone know if it is possible to have a script set the ‘Input’ and ‘Output’ tabs of the Sound control panel to a specific device?
The reason for this is that when I plug in a Plantronics USB headset prior to making a Skype call, the Input & Output tabs don’t always switch to the headset. It’s really strange - sometimes it works, others not. So everytime I plug the headset in, I’m forced to first check that my headset is selected in both Input & Output in the Sound control panel. Then I start Skype, and have to check that the headset is also selected for ‘Audio Input’ and ‘Audio Output’ in Skype’s ‘Audio’ preferences.
Ultimately I’d like to have a script that does both locations (ie Sound control panel & Skype’s Audio tab).
If these applications aren’t scriptable, is there anyway to write a script that pretty much replicates the mouse’s movements? I have seen a script (attached below) that seems to control iCal by telling it which menu to select, and which keys to press…can this be done in all applications?
Thanks in advance!
Matthew
Here’s the script that seems to operate by being a ‘phantom mouse & keyboard’:
tell application "iCal" to activate
tell application "System Events"
tell menu item "Back up Database." of menu "File" of menu bar 1 of application process "iCal" to click
delay 1
keystroke "iCal" & todaysDate
keystroke "d" using command down
delay 1
keystroke return
delay 5
end tell
Model: iMac G5 2Ghz
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
Hi Bruce
Thanks so much for finding that topic for me. I admit to being embarassed that I didn’t find it myself, although I did seach both the forum and the web using Google. I must have been barking up the wrong tree!
I took this script and it works perfectly:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
reveal (first anchor of current pane whose name is "input")
end tell
tell application "System Events"
launch
tell process "System Preferences"
set theRows to every row of table 1 of scroll area 1 of tab group 1 of window 1
repeat with aRow in theRows
if (value of text field 1 of aRow) is equal to "Plantronics Headset" then
set selected of aRow to true
exit repeat
end if
end repeat
end tell
end tell
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
reveal (first anchor of current pane whose name is "output")
end tell
tell application "System Events"
launch
tell process "System Preferences"
set theRows to every row of table 1 of scroll area 1 of tab group 1 of window 1
repeat with aRow in theRows
if (value of text field 1 of aRow) is equal to "Plantronics Headset" then
set selected of aRow to true
exit repeat
end if
end repeat
end tell
end tell
quit application "System Preferences"
Shanyno (who posted the original question) had this to say, but I can’t figure out who to ‘reverse’ the script’s action, or get Skype’s preferences to ‘follow’ as he suggests. Do you know how?
Thanks for you help - even if I only have this script, it’ll make things easier. If I can get it ‘reversing’ and then Skype ‘following’, it’ll be awesome!
Regards
Matthew
Hi Jacques
Woah, you’re everywhere!! Is there anything you can’t script?!
I haven’t tried your scipt yet, but will do later today.
Does it ‘reverse’ the settings (ie so when I unplug the Plantronics headset) it goes back to ‘normal’?
What about the Skype preferences?
Regards
Matthew
Great script. Thanks.
Just one change I made. My USB device name had hidden spaces at the end of the name so I changed
if (value of text field 1 of aRow) is equal to "USB Audio Device" then
to
if (value of text field 1 of aRow) contains "USB Audio Device" then