• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Output Audio Device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Output Audio Device


  • Subject: Re: Output Audio Device
  • From: kai <email@hidden>
  • Date: Wed, 1 Nov 2006 23:07:30 +0000


On 1 Nov 2006, at 17:48, Adam Bell wrote:

When headphones, external speakers, or neither of the above (internal speaker) are connected, the Sound pane of System Preferences indicates the change. To be able to detect the configuration from an AppleScript, however, the only means I've been able to find is this one:
-----
activate application "System Preferences"
tell application "System Events" to tell process "System Preferences"
click button "Sound" of scroll area 1 of window "System Preferences"
delay 1
set S to value of text field 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound"
end tell
-----
where the value of 'S' will be 'Internal Speakers', 'Line Output', or 'Headphones', depending on the hardware setup.


That's a rather brute force approach (which only works, BTW, if System Preferences is not running when it's invoked).

[snip]

You also need to make sure the relevant tab is selected, Adam. When I ran the above script, for example, I got the result "Basso" - because the last sound tab selected here was "Sound Effects".

1. Is there a cleaner way to open the sound pane directly?

In a word, yes. This should work regardless of System Preferences' current status - and with no explicit delay required:


----------------

tell application "System Preferences"
	reveal anchor "output" of pane id ¬
		"com.apple.preference.sound"
end tell
tell application "System Events"
	set S to value of text field 1 of row 1 of table 1 of ¬
		scroll area 1 of tab group 1 of window "Sound" of ¬
		application process "System Preferences"
end tell

----------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Output Audio Device
      • From: kai <email@hidden>
References: 
 >Output Audio Device (From: Adam Bell <email@hidden>)

  • Prev by Date: Re: Output Audio Device
  • Next by Date: Re: Ejecting the tray on CD/DVD Drive
  • Previous by thread: Output Audio Device
  • Next by thread: Re: Output Audio Device
  • Index(es):
    • Date
    • Thread