(* Modified from the script found at http://www.oreillynet.com/mac/blog/2006/07/applescript_audio_output_switc.html to switch between Digital output and Internal speakers, to act as a mute when using Digital out *) (* This script toggles between two audio outputs in the "Sound" pane in "System Preferences" and adjusts the volume. Modified from a script at http://forums.macosxhints.com/showthread.php?t=45384 to add volume control and GUI scripting detection. --David Battino, www.batmosphere.com. USES GUI SCRIPTING; "ENABLE ASSISTIVE DEVICES" OPTION MUST BE CHECKED IN THE "UNIVERSAL ACCESS" PREFERENCE PANE *) 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" if (selected of row 3 of table 1 of scroll area 1) then -- Digital out is selected set selected of row 1 of table 1 of scroll area 1 to true tell application "Finder" set volume 0 end tell else set selected of row 3 of table 1 of scroll area 1 to true -- Internal speakers are selected tell application "Finder" set volume 2 end tell end if end tell end tell tell application "System Preferences" to quit on error tell me to activate display dialog "Problem selecting audio device." 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