Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Getting info from UI Scripting

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Unknown MIME type  
Author Message
Ian A. York

External


Since: Jun 21, 2004
Posts: 26



(Msg. 1) Posted: Wed Jul 28, 2004 6:55 pm
Post subject: Getting info from UI Scripting
Archived from groups: alt>comp>lang>applescript (more info?)

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.
This info is apparently available to the UI Scripting inspector, because I
can get a panel that shows:

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

<AXApplication: “System Preferences”>
<AXWindow: “Sound”>
<AXTabGroup>
<AXScrollArea>
<AXTable>
<AXRow>
<AXTextField>

Attributes:
AXRole: “AXTextField”
AXRoleDescription: “text field”
AXHelp: “(null)”
AXValue (W): “Internal speakers”
AXEnabled: “1”
AXFocused: “0”
AXParent: “<AXRow>”
AXWindow: “<AXWindow: “Sound”>”
AXPosition: “x=62 y=309”
AXSize: “w=252 h=18”
AXSelectedText: “(null)”
AXSelectedTextRange: “(null)”
AXNumberOfCharacters: “17”
AXVisibleCharacterRange: “pos=722 len=17”

Actions:
AXConfirm - confirm


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

The AXValue (W): "Internal speakers"
changes to
AXValue (W): " Headphones”

when the speakers are plugged in. I think I should be able to grab that
info somehow, but none of the things I've tried work.

(Apologies if there are some funky characters in there -- I just
cut-and-posted from UI Inspector.)

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 
Back to top
Login to vote
Ian A. York

External


Since: Jun 21, 2004
Posts: 26



(Msg. 2) Posted: Fri Jul 30, 2004 8:54 am
Post subject: Re: Getting info from UI Scripting [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Scripting RealPlayer 10 - Is it possible to instruct Real Player to open a specific URL? I've tried a few different things, and the best I can do is to get RealPlayer to start up. Can't get it to recognize the URL... tell application "RealPlayer" open..

UI Scripting Beta -

UI Scripting: why this won't work - I found this script on Apple 's site using UI scripting to import pictures of a folder into iPhoto: this_item is the choosen folder. // -- convert the file reference to UNIX style set this_path to the POSIX path of this_item -- bring the target..

UI Scripting: Does it work? - Hello, I always get the strangest results when I try to script "System Events". For example: ------------------------------------ tell application "System Events" tell menu bar 1 of process "Finder" click menu...

Need help scripting TextEdit - I use TextEdit to keep a logbook, and I have a fairly simple script to open TextEdit and to create a time stamp (see script below). After the script runs, I have to scroll down to the end of the document and paste the timestamp. I want the timestamp to....
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]