Re: Consistency of arrays of AXUIElementRefs
Re: Consistency of arrays of AXUIElementRefs
- Subject: Re: Consistency of arrays of AXUIElementRefs
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 05 Jan 2008 16:48:05 -0500
- Thread-topic: Consistency of arrays of AXUIElementRefs
on 2008-01-05 3:25 PM, David Hoerl at email@hidden wrote:
> Using UI Browser to poke around in a few apps, looking at their
> hierarchies, one often sees an element with a "children" array of
> AXUIElementRefs. In some cases you see several (UI Browser shows
> these as "group (group n)", where n starts at one and increases by
> one for each similar type).
>
> Well, these items, at this level, appear to have no other unique
> identifier (unless you count their position or size, etc - what I
> mean is they have no unique name).
>
> So, the question becomes: given some app at version x.y.z on a given
> OS (Leopard), will their ordinal position in the array stay constant
> over time?
>
> If not, then I'm guessing I will have to traverse all possible paths
> to my final destination, somewhat like a network routing algorithm
> that tries all possible paths to reach the destination.
The index number that UI Browser shows for UI elements is calculated from
the ordering it finds in the particular container in the particular target
application. There is no reason to expect that the indexes will remain the
same in different versions of an application. And even within a single
version of an application, some UI element indexes will change during a
working session; for example, when the user deletes a row from a table.
There is at least one other case where the index numbers change by design
during a working session: the indexes of windows always reflect their
current front-to-back ordering in the Finder.
The index numbers in UI Browser are not a feature of the Accessibility API.
They are included in UI Browser only because they are useful in
AppleScript's GUI Scripting technology. As it happens, GUI Scripting and UI
Browser calculate UI element indexes in the same way, so the index you see
in UI Browser can be used in a GUI Scripting script to access the same UI
element. In fact, the indexing feature of UI Browser is one of the more
important benefits it offers to users of GUI Scripting, who are an important
segment of our market. Users of GUI Scripting are well aware of the vagaries
of indexed references, but scripts tend to be designed for relatively short
lifetimes; referring, for example, to a menu item in a menu by index number
instead of title can be perfectly functional in a one-off AppleScript
environment.
There are a variety of ways you can distinguish between same-level child UI
elements, but they all depend on the way the particular target application
was implemented. Sometimes, child UI elements have unique titles. Other
times, they have unique Accessibility description properties. Or they may
have unique tooltip text. But very often they are distinguished only by
their value, and there is no guarantee that the values will be unique.
In short, traversing the Accessibility hierarchy is sometimes the only
solution.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden