Skype AppleScript: Switching Audio
I fiddled around today trying to figure out how to get Skype on the Mac to effectively switch from using the buit-in mic and speakers to using my bluetooth headset (and then back again).
I'm using a MacBook Pro and a Jabra BT530 bluetooth headset.
After starting Skype, through trial and error I figured out the right sequence of events to connect my bluetooth headset to the computer and then change both the Mac system preferences and the Skype preferences to make this work:
- Establish the bluetooth connection to the headset
- Open the system preferences and change the audio input and output to use the bluetooth headset
- Open the Skype preferences and change the audio input and output to use the bluetooth headset
Once this sequence was established, the AppleScript could be written:
Audio%20-%20Bluetooth.scpt
Here is the script to change back to using the built in audio: Audio%20-%20Mac.scpttell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
if UI elements enabled then
try
tell application process "System Preferences"
tell tab group 1 of window "Sound"
click radio button "Output"
set selected of row 2 of table 1 of scroll area 1 to true
set deviceselected to "Jabra Headset"
set verbal_description to "Bluetooth Headset Now Active"
tell application "Finder"
set volume 7
end tell
end tell
end tell
tell application "System Preferences" to quit
on error
tell me to activate
display dialog "Please plug in the headset." buttons {"Whoops!"} default button 1
end try
else --GUI scripting is disabled
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
end tell
display dialog "Please check the box called \"Enable access for assistive devices.\"" buttons {"Okay"} with icon 1 default button 1
end if
end tell
tell application "Skype"
activate
send command "SET AUDIO_OUT IOBluetoothSCOAudioEngine_new:00-1d-82-18-ec-e6" script name "something"
send command "SET AUDIO_IN IOBluetoothSCOAudioEngine_new:00-1d-82-18-ec-e6" script name "something"
end tell
These scripts were adapted from: http://www.oreillynet.com/mac/blog/2006/07/applescript_audio_output_switc.htmltell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
if UI elements enabled then
try
tell application process "System Preferences"
tell tab group 1 of window "Sound"
click radio button "Output"
set selected of row 1 of table 1 of scroll area 1 to true
set deviceselected to "Built-in Output"
set verbal_description to "Built-in Output Now Active"
tell application "Finder"
set volume 7
end tell
end tell
end tell
tell application "System Preferences" to quit
on error
tell me to activate
display dialog "Please plug in the headset." buttons {"Whoops!"} default button 1
end try
else --GUI scripting is disabled
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
end tell
display dialog "Please check the box called \"Enable access for assistive devices.\"" buttons {"Okay"} with icon 1 default button 1
end if
end tell
tell application "Skype"
activate
send command "SET AUDIO_OUT AppleHDAEngineOutput:0" script name "something"
send command "SET AUDIO_IN AppleHDAEngineInput:1" script name "something"
end tell
As you switch settings in Skype and run this script, change the commented lines to switch between reading the audio input and output settings. Take the output from this script and replace the similar lines in the earlier scripts.tell application "Skype"
activate
send command "GET AUDIO_IN" script name "something"
--send command "GET AUDIO_OUT" script name "something"
end tell
Labels: applescript, mac, skype

1 Comments:
This is very useful and ideal for what I want to do, however it just doesnt work for me. I was on Skype 2.8 but it wouldnt even recognise my BT audio_in using your "get" script. Now I downgraded to 2.7, the "get" script works, but still the output/input won't change! The system prefs section works perfectly. Am I missing something? I checked other commands like CALL and HOOK ON, they work ok. Appreciate your help.
Post a Comment
Links to this post:
Create a Link
<< Home