Using an external reference to a UI element
Using an external reference to a UI element
- Subject: Using an external reference to a UI element
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 22 Dec 2003 06:34:18 -0500
My scriptable application knows how to get an AXUIElementRef internally. It
is also able to export most of the attributes of the AXUIElementRef as
AppleScript properties. However, I would prefer to simply export a reference
to the UI element and let the scripter use GUI Scripting to do the rest (get
and set attributes, etc.).
But one important feature is missing: my app can't export a reference to the
AXUIElementRef itself in such a way that a scripter could use it to script
the System Events application (i.e., GUI Scripting).
Is there a technique I can use to export an AXUIElementRef via AppleScript
in such a way that GUI Scripting can pick it up and use it?
The only trick I have thought of so far is to export a list of indexes
reflecting the path of the UI element. In other words, my app would export a
'path indexes' property such as '{1, 9, 3}', and the scripter would tell app
"System Events" to 'get UI element (item 1 of path indexes) of UI element
(item 2 of path indexes) of UI element (item 3 of path indexes) of
application "X"'.
For example, this works:
set indices to {1, 3}
tell application "System Events"
tell process "TextEdit"
set myElement to UI element (item 1 of indices)
repeat with idx from 2 to (count indices)
set myElement to (UI element (item idx of indices) of myElement)
end repeat
get subrole of myElement
end tell
end tell
--> "AXCloseButton"
Is there a better way? So that a scripter could do something like this? --
tell application "My App" to set wow to current element
tell application "System Events"
tell process "TextEdit"
get subrole of wow
--or this:
--get subrole of wow as UI element
--or this:
--get subrole of a reference to wow
--or this:
--set myElement to UI element whose elementRef is elementRef of wow
--get subrole of myElement
end tell
end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
accessibility-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/accessibility-dev
Do not post admin requests to the list. They will be ignored.