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

jorettig

macrumors newbie
Original poster
Feb 11, 2014
1
0
Hey,

sorry, I'm an absouletly newbie in the field of mac programming. But I have programming experience in general.

I have here a new headset and I want the mac to switch automatically Audio Input and Output to the headset, when it's plugged in.

I found this code here:

http://www.oreillynet.com/mac/blog/2006/07/applescript_audio_output_switc.html

I renamed the headset but I got a fault. The event protocoll says:

Code:
tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
	get UI elements enabled
		--> true
	click radio button "Output" of tab group 1 of window "Sound" of application process "System Preferences"
		--> error number -1728 from window "Sound" of application process "System Preferences"
end tell
tell current application
	activate
end tell

So in my opinion the script tries to select the 'Output' Radio Button, but doesn't find it. What is the problem here? Im using Mavericks.

Can I modify the script, that it starts automatically, when the headset ist plugged in?

Thanks,
jorettig
 
Last edited by a moderator:

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
What is the problem here? Im using Mavericks.

Is Applescript Editor allowed to control the computer? See thumbnail. Works here and I'm on Mavericks too.

Code:
tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
	get UI elements enabled
		--> true
	click radio button "Output" of tab group 1 of window "Sound" of application process "System Preferences"
		--> radio button "Output" of tab group 1 of window "Sound" of application process "System Preferences"
end tell

Result:
radio button "Output" of tab group 1 of window "Sound" of application process "System Preferences" of application "System Events"
 

Attachments

  • Screen Shot 2014-02-11 at 22.11.41.png
    Screen Shot 2014-02-11 at 22.11.41.png
    115.8 KB · Views: 85
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.