Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

djschep

macrumors member
Original poster
May 23, 2012
34
0
Hey guys,

I want to make a quick script i can run to switch the audio inputs and outputs from the default internal speaker/microphone to the speakers and mic on my headset. I dont know anything about apple scripts and dont know the commands for changing the audio. This is the barebones of what i want the script to do:

if Audio Output = Internal Speakers
set Audio Output = Logitech G390 Headset
set Audio Input = Logitech G930 Headset

elseif Audio Output = Logitech G930 Headset
set Audio Output = Internal Speakers
set Audio Output = Internal Microphone

end

Also, is there a way to assign this script to a button in the menu bar?
Thanks guys!
 

0000111

macrumors member
Jul 24, 2014
97
18
Hey guys,

I want to make a quick script i can run to switch the audio inputs and outputs from the default internal speaker/microphone to the speakers and mic on my headset. I dont know anything about apple scripts and dont know the commands for changing the audio. This is the barebones of what i want the script to do:

if Audio Output = Internal Speakers
set Audio Output = Logitech G390 Headset
set Audio Input = Logitech G930 Headset

elseif Audio Output = Logitech G930 Headset
set Audio Output = Internal Speakers
set Audio Output = Internal Microphone

end

Also, is there a way to assign this script to a button in the menu bar?
Thanks guys!

I have a way that's quite simple, not a script, and in your menu bar. Press option while clicking on the volume button, and you can control your computer's audio routing.

Yes, it won't automate it as much as you desire, but it's close!
 

djschep

macrumors member
Original poster
May 23, 2012
34
0
I have a way that's quite simple, not a script, and in your menu bar. Press option while clicking on the volume button, and you can control your computer's audio routing.

Yes, it won't automate it as much as you desire, but it's close!

Cool! I never knew that it could be that simple, I'll use this in the mean time. The reason I ask this is as much to learn as anything else.
Thanks 0000111 :D
 

0000111

macrumors member
Jul 24, 2014
97
18
cool! I never knew that it could be that simple, i'll use this in the mean time. The reason i ask this is as much to learn as anything else.
Thanks 0000111 :d

:D

EDIT: that's the weirdest smiley encoding I've dealt with. I click on the same green guy you gave me but the forum won't take it. Oh well!
EDITx2: fixed it :D
 

Nedanator

macrumors newbie
Apr 11, 2008
28
0
Derby, UK
I was looking for something similar a few years ago. I came across a script and adapted it to my needs (can't remember where I found it, was a long time ago). Using BetterTouchTool I can run the script by hitting F15 on my keyboard.

Try this: (If you're using the latest version of OS X, you'll need to run it once to in order to give the script access to the system, then run it again to actually use it.) (Also, it doesn't make any changes to audio input as far as i'm aware, so you'll have to add that yourself.)
Code:
(*
USES GUI SCRIPTING; "ENABLE ASSISTIVE DEVICES" OPTION MUST BE CHECKED IN THE "UNIVERSAL ACCESS" PREFERENCE PANE
*)

set tTitle to "Audio Switcher v3.0"

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 2 of table 1 of scroll area 1) then --headset is selected
						set selected of row 1 of table 1 of scroll area 1 to true
						set deviceselected to "Built-in Output"
						tell application "Finder"
							set volume 2
						end tell
					else
						set selected of row 2 of table 1 of scroll area 1 to true
						set deviceselected to "HDMI"
					end if
				end tell
			end tell
			tell application "System Preferences" to quit
			display dialog "Audio output is now. . . " & return & return & "* " & deviceselected with title tTitle buttons {"Good"} default button 1 giving up after 5
		on error
			tell me to activate
			display dialog "Please plug in the headset." buttons {"Okay"} 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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.