Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created August 20, 2010 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrunning/541430 to your computer and use it in GitHub Desktop.
Save jrunning/541430 to your computer and use it in GitHub Desktop.
set skypeDevices to {headset:{}, speaker:{}}
set sysDevices to {headset:{}, speaker:{}}
-- CONFIG
-- The exact names of your input and output devices found in Skype > Preferences > Audio
-- Headset device:
set headset of skypeDevices to {input:"Avnera Audio Device", output:"Avnera Audio Device", ringer:"Avnera Audio Device"}
-- Speaker/microphone devices:
set speaker of skypeDevices to {input:"Built-in Microphone Internal microphone", output:"Built-in Output Internal Speakers", ringer:"Built-in Output Internal Speakers"}
-- The indices of your input and output devices in System Preferences > Sound > Output and Input
-- Headset device
set headset of sysDevices to {input:3, output:2}
-- Speaker/microphone devices
set speaker of sysDevices to {input:1, output:1}
-- USAGE
-- Use your configured speakers and the associated microphone:
my toggleSpeaker(skypeDevices, sysDevices)
-- Use your configured headset and the associated microphone:
--my toggleHeadset(skypeDevices, sysDevices)
-- script
on toggleHeadset(skypeDevices, sysDevices)
setSkypeDevices(headset of skypeDevices)
setSysDevices(headset of sysDevices)
say "Headset." using "Trinoids"
end toggleHeadset
on toggleSpeaker(skypeDevices, sysDevices)
setSkypeDevices(speaker of skypeDevices)
setSysDevices(speaker of sysDevices)
say "Speaker." using "Trinoids"
end toggleSpeaker
on setSkypeDevices(mode)
set timeoutSecs to 2.0
tell application "Skype" to activate
tell application "System Events"
tell process "Skype"
keystroke "," using command down
set prefs to front window
click UI element "Audio" of tool bar 1 of prefs
set dropDowns to group 1 of group 1 of prefs
set outputDrop to pop up button 1 of dropDowns
set inputDrop to pop up button 2 of dropDowns
set ringerDrop to pop up button 3 of dropDowns
-- set Audio output device
click outputDrop
click menu item (output of mode) of menu 1 of outputDrop
-- set Audio input device
click inputDrop
click menu item (input of mode) of menu 1 of inputDrop
-- set Ringing device
click ringerDrop
click menu item (ringer of mode) of menu 1 of ringerDrop
end tell
end tell
end setSkypeDevices
on setSysDevices(mode)
tell 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"
select row (output of mode) of table 1 of scroll area 1
click radio button "Input"
select row (input of mode) of table 1 of scroll area 1
end tell
end tell
end try
end if
end tell
end setSysDevices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment