Help with IAccessible objects

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
footballmonkeey
Posts: 16
Joined: 03 Jun 2016, 12:32

Help with IAccessible objects

15 Nov 2017, 10:54

Hi,

Firstly I would like to say that I'm pretty new to IAccessible objects, so I definitely do not know all there is to know and have probably misunderstood some concepts. Can someone tell me why the Acc library Viewer https://autohotkey.com/boards/viewtopic.php?t=26201 does not display the same tree hierarchy as Microsoft Inspect https://msdn.microsoft.com/en-us/librar ... s.85).aspx. I tried out both in Word and they got different amount of children from the main (topmost parent) window, and the child objects of the main window found in Inspect is found different places in Acc Viewer (pictures below). Does Acc library retrieve the children differently?

I for some reason I have trouble getting down the tree hierarchy of an IAccessible object, for example from word to the bold button, because I can't get the IAccessible object of a child (I probably have misunderstood the way of retrieving this), because the output of AccessibleChildren function https://msdn.microsoft.com/en-us/librar ... s.85).aspx, is a Variant, and I'm not sure how to use this to access children of children and so on.

Any clarification would be greatly appreciated, or maybe point me in the right direction to learn this.

Inspect
Image

Acc Viewer
Image
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Help with IAccessible objects

15 Nov 2017, 11:09

AFAIK, they use different systems:
Microsoft Active Accessibility - Wikipedia
https://en.wikipedia.org/wiki/Microsoft ... essibility
Microsoft UI Automation - Wikipedia
https://en.wikipedia.org/wiki/Microsoft_UI_Automation

The Acc functions always start from a window or control, so to get the full hierarchy (path) make sure you put a rectangle around the whole window (easier if you resize it to make it not fullscreen), or a control, and then navigate to the element.

[EDIT:] I tested, and this seems to be one of the most fiendish hierarchies I've seen in an Acc situation:

Code: Select all

q:: ;word 2007 - toggle bold on/off
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "4.3.4.1.4.1.4.1.4.1.4.14.1.1.2.10", 0, "ahk_id " hWnd)
MsgBox, % oAcc.accName(0)
oAcc.accDoDefaultAction(0)
oAcc := ""
return
I do have it planned, in future, to write something to click on an element, and create the relevant Acc_Get line.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
footballmonkeey
Posts: 16
Joined: 03 Jun 2016, 12:32

Re: Help with IAccessible objects

15 Nov 2017, 12:31

Thank you very much sir!

I wasnt actually sure how to use the Acc_Get, but looking up the hierarchy to the bold button in Word 2016, changing the number in your example and it worked smoothly.

I was thinking of creating something like this Acc_findChild(Name, Role, hWnd). Putting it in action in the dummy example with the bold button, it would be used like Acc_findChild("Bold", "push button", hWnd) and it would search through the whole hierarchy from the top until it finds the correct combination and then probably do a accDoDefaultAction. It could probably take a couple of hundred milliseconds going through a hierarchy as large as that one, but it would work in my software if there were any updates changing the hierarchy. It would the also have worked in both Word 2007 and 2016, because it doesnt have to know the exact child path.
But there are probably some ways to make it go faster, one I can think of would be storing the ChildPath after found, in external file, then first checking if the child path has the correct Name and role; if no, then find the new child path by going through the whole hierarchy, store it, and then DoDefaultAction.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus and 216 guests