In article ,
Ian A. York wrote:
>
>How can I get information using UI scripting? For example, let's say I
>want to do one thing if speakers are plugged, another if they're not.
Just in case anyone cared, an answer turns out to be something like
this:
----------------------------------------------------
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
tell application "System Events"
tell process "System Preferences"
click radio button 2 of tab group 1 of window "Sound"
set Which_Output to (get value of text field 1 of row 1 of
table 1 of scroll area 1 of tab group 1 of window "Sound")
end tell
end tell
tell application "System Preferences" to quit
----------------------------------------------------
Seems like the temptation to use names for UI elements, even when UI
Brower offers them, whould be resisted (e.g. "Radiobutton "output""
should be called "radio button 2"). As far as I can tell figuring out
which number goes with which button is mostly trial and error.
The script here is still pretty much useless, but it was a good exercise
for me.
Ian
--
Ian York (iayork@panix.com) <http://www.panix.com/~iayork/>
"-but as he was a York, I am rather inclined to suppose him a
very respectable Man." -Jane Austen, The History of England
>> Stay informed about: Getting info from UI Scripting