Acc library (MSAA) and AccViewer download links

Post your working scripts, libraries and tools for AHK v1.1 and older
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Acc library (MSAA) and AccViewer download links

11 Jun 2019, 03:20

I have such a problem.
---------------------------
iWB2 Learner UPDATED.ahk
---------------------------
Error: Call to nonexistent function.

Specifically: Acc_ObjectFromPoint(child).accSelect(0x3, child)

Line#
112: temp := clipboard := %A_GuiControl%
113: ToolTip,"clipboard= " (StrLen(temp) > 40 ? SubStr(temp,1,40) "..." : temp)
114: SetTimer,RemoveToolTip,1000
115: }
116: Else
116: if (A_GuiControl = "TView")
116: {
---> 117: Acc_ObjectFromPoint(child).accSelect(0x3, child)
118: Hotkey,~LButton Up,On
120: if TV_GetParent(TVsel:=TV_GetSelection())
120: {
121: TV_GetText(text, TVsel)
122: RegExMatch(text, "\d+", child)
123: clicked := Stored.pelt.childNodes[child]
124: }

The program will exit.
---------------------------
Okey
---------------------------
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

11 Jun 2019, 21:37

- 3 possible solutions:
- (1) Create a folder called 'Lib' (in the same folder as the AutoHotkey exe), and copy Acc.ahk and Anchor.ahk into that folder.
- (2) Edit 'iWB2 Learner UPDATED.ahk', add these 2 lines at the top (or bottom):

Code: Select all

#Include %A_ScriptDir%\Acc.ahk
#Include %A_ScriptDir%\Anchor.ahk
- (3) Edit 'iWB2 Learner UPDATED.ahk', add the contents of Acc.ahk and Anchor.ahk into it at the bottom (or top).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Acc library (MSAA) and AccViewer download links

12 Jun 2019, 02:57

jeeswg wrote:
11 Jun 2019, 21:37
- 3 possible solutions:
- (1) Create a folder called 'Lib' (in the same folder as the AutoHotkey exe), and copy Acc.ahk and Anchor.ahk into that folder.
- (2) Edit 'iWB2 Learner UPDATED.ahk', add these 2 lines at the top (or bottom):

Code: Select all

#Include %A_ScriptDir%\Acc.ahk
#Include %A_ScriptDir%\Anchor.ahk
- (3) Edit 'iWB2 Learner UPDATED.ahk', add the contents of Acc.ahk and Anchor.ahk into it at the bottom (or top).
Yeah, that worked. Thanks.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Acc library (MSAA) and AccViewer download links

01 Sep 2019, 08:52

There is a bug in AccViewer.
To recreate this bug You have to:
1) Install the next extension: in Chrome::::
https://chrome.google.com/webstore/detail/floating-for-youtube-exte/egncdnniomonjgpjbapalkckojhkfddk
2) Run Google Chrome with --force-renderer-accessibility flag.
3) Run any Youtube video in this extension.
If You run AccViewer to get object from floating-for-youtube window - You will get nothing.
If You run AccExplorer from MSDN - You will get object and path.
https://github.com/blackrosezy/gui-inspect-tool/blob/master/AccExplorer32.exe
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Acc library (MSAA) and AccViewer download links

01 Sep 2019, 15:57

@malcev, thank you for linking to this tool!
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Acc library (MSAA) and AccViewer download links

02 Sep 2019, 05:51

tmplinshi wrote:
10 Oct 2018, 15:57
I made some changes to the AccViewer:
  • Display all 'State' and its constant name/value
  • Display constant name/value of 'Role'
  • Changed the hotkey from "Ctrl+/" to "Ctrl+F12"
  • Added 'HotTracking' checkbox
  • Increased GUI Size
https://gist.github.com/tmplinshi/0fcb8655c1402a3662ac048d0d974915

Image
There is a bug in your code.
Open Chrome, navigate to any Youtube video, double click with right mouse button on it, choose "picture in picture".
Then try to get path of this "picture in picture youtube video".
Using Your tool - You will get "5".
But if You use original AccViewer, then You will get the right path - "4.1.5".
https://raw.githubusercontent.com/Drugoy/Autohotkey-scripts-.ahk/master/DevTools/AccViewer.ahk
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Acc library (MSAA) and AccViewer download links

02 Sep 2019, 07:31

@malcev I checked the original AccViewer that I have, it produce the same result as my modified version "5". The AccViewer.ahk you provide do produce "4.1.5".

So I compared the two versions, and found the reason to it.

Code produce path "5":

Code: Select all

	Acc_ObjectFromWindow(hWnd, idObject = 0)
	{
		If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
			Return	ComObjEnwrap(9,pacc,1)
	}
Code produce path "4.1.5":

Code: Select all

	Acc_ObjectFromWindow(hWnd, idObject = 0)
	{
		Acc_Init()
		If	DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x%_offset1%19B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
		Return	ComObjEnwrap(9,pacc,1)
	}
The difference between the above two Acc_ObjectFromWindow functions:
  • 0x719B3800AA000C81
  • 0x%_offset1%19B3800AA000C81
The value of _offset1 is 10, but it's not a global variable, or even it was, MsgBox % 0x%_offset1%19B3800AA000C81 will be empty, that means you can just replace 0x%_offset1%19B3800AA000C81 to 0 to get the result path "4.1.5".
I think this was an accident that someone made a replacement to 7 with %_offset1% :D .
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Acc library (MSAA) and AccViewer download links

02 Sep 2019, 17:45

I do not think that it will be correct.
I do not understand why in this function:

Code: Select all

GetAccPath(Acc, byref hwnd="") {
	hwnd := Acc_WindowFromObject(Acc)
	WinObj := Acc_ObjectFromWindow(hwnd)
	WinObjPos := Acc_Location(WinObj).pos
	while Acc_WindowFromObject(Parent:=Acc_Parent(Acc)) = hwnd {
		t2 := GetEnumIndex(Acc) "." t2
		if Acc_Location(Parent).pos = WinObjPos
			return {AccObj:Parent, Path:SubStr(t2,1,-1)}
		Acc := Parent
	}
	while Acc_WindowFromObject(Parent:=Acc_Parent(WinObj)) = hwnd
		t1.="P.", WinObj:=Parent
	return {AccObj:Acc, Path:t1 SubStr(t2,1,-1)}
}
we need this expression

Code: Select all

		if Acc_Location(Parent).pos = WinObjPos
			return {AccObj:Parent, Path:SubStr(t2,1,-1)}
If we remove it - code produce path "4.1.5".
And if We need to get object and path from Chrome We should rewrite GetAccPath and GetEnumIndex functions.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

02 Sep 2019, 18:25

There may be some ideas here re. alternative Acc functions (for Acc paths):
How to get the full ACC path for control on cursor? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=56470&p=254902#p254902
AccessibleObjectFromWindow does not execute method accFocus in Firefox - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=60278&p=254907#p254907

You could try this for getting Acc paths (JEE_AccGetTextAll):
Acc: get text from all window/control elements - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40615

@malcev: It would be helpful, after a while/after reflecting, when the picture is clearer, if you could summarise what problems you have seen with Acc.ahk and/or AccViewer, specifically problems with the versions in the AccPack zip. Thanks. [EDIT: Or you could create an alternative AccPack zip with proposed updated scripts.]

Thanks also for the great links re. YouTube and Acc alternatives. Much appreciated.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Acc library (MSAA) and AccViewer download links

03 Sep 2019, 20:25

There is an error in library from the first post link
[AccViewer.ahk]
Autohotkey-scripts-.ahk/AccViewer.ahk at master · Drugoy/Autohotkey-scripts-.ahk · GitHub
https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/DevTools/AccViewer.ahk
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x%_offset1%19B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
And I think that algorithm for getting path in AccViewer.ahk is wrong.
There are some situations in Google Chrome when several parent objects have the same location as child object and how we can choose which one of them to take?
May be it will be better to get path of searched object with creating tree of all objects and comparing each object properties such as name, value, state, location... with our searched object properties?
The stupid one
Posts: 3
Joined: 08 Jan 2020, 18:44

Re: Acc library (MSAA) and AccViewer download links

07 Mar 2020, 21:55

Hi,
I would like to know, how to use the acclocation, parent, children.

I have done something like

try vLocation := oAcc.accLocation(vChildID)
try vParent := oAcc.accParent(vChildID)
try vChildren := oAcc.accChildren(vChildID)

They have not succeeded in any of the applications.

Did I wrongly call the function or missunderstood it?
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Acc library (MSAA) and AccViewer download links

14 Feb 2021, 23:26

Parsing Acc tree objects upwards proved to be tricky (tmplinshi's Acc Viewer & serzh82saratov's AhkSpy fail to yield correct path in some UI-s). So the idea is to parse downwards based on Get Acc children. Doing this got the idea of a new way for upward, but in the end wasn't any better then beforementioned (now completely commented out).
Issues: slower and for highly branched Acc like in IE may crash if there are a lots of tabs opened, probably due to Ahk recursive call limitation (ca 350 <---- [Edit]).
- Esc will stop the parsing
- s, d, f, e will move mouse cursor by one pixel to left (s), down (d), right (f) and up (e) - alongside w/ arrow keys
- ^\ starts framing elements w/o pressing LButton down, F3 stops it (evaluates current selection)
- pressing Ctrl before releasing LButton will use alternative parsing upwards (not for treeView)

P.s.: Very little tested, but looks promising.
P.p.s.:
1. Example of use if Path is not available (N/A).
2. Check box in browser.
Attachments
Acc Viewer RP3.5.ahk
(69.04 KiB) Downloaded 472 times
Last edited by rommmcek on 10 Apr 2021, 10:52, edited 3 times in total.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Acc library (MSAA) and AccViewer download links

10 Apr 2021, 09:57

- Bug fixed (supplemented criteria to stop parsing the Acc tree).
- Thanks to malcev improved initializing of the Acc.
- In case of N/A for the AccPath all values are displayed so parent AccPath can be (empirically) found (not user friendly - To do: automate it...)
Janusz
Posts: 89
Joined: 18 Dec 2020, 17:47

Re: Acc library (MSAA) and AccViewer download links

16 Apr 2021, 08:16

I would like to publicly congratulate The developer of aac.ahk long library. Yours long development time can allow advanced programmer to even create screen reader by using Autohotkey. Sure, there are several freely available screen readers, but if somebody have a new invention on this field of development, it is possible. The most complex task is always inter process communication such as make virtual browser for Internet Explorer, Microsoft Edge of other similar browsers. In The world of Linux operating system, Orca screen reader is completely written in Python. There is no C or C++ libraryes to get information while using inter process communication. I Am meaning, that Orca source do not contain source files in such language. Sure, some Python bindings may contain some reference to native .so libraryes. Interprocess communication is not easy also because of memory leaks. Before NVDA developers have started to use C++ languages, they were used COm types and memory allocations have been dramatically increased. It would be A good experiment to try it with Autohotkey. Using object model of IE without external C or C++ DLL, only from plain Autohotkey. And observe, how many MB will autohotkey.exe allocate. Thank you for yours library again, very well done. I can not use accwiever, because I do not see at all, and when I Am using screen reader build in speaking mouse, and if I only simple move with mouse pointer till i AM listenning speech synthesizer feetback, and when I press CTRL+/ nothing happens. Sure, when I execute accwiever.ahk it display its fully accessible GUI, but all editable fields do not contain information at all.
foxdanger
Posts: 83
Joined: 11 Jun 2019, 13:48

Re: Acc library (MSAA) and AccViewer download links

04 Feb 2022, 15:19

Hi! First of all, thx for this class. Is amazing and it is helping me a lot.

I have a question that I think is simple:

There's a way to do something like this:

Code: Select all

functionX (){
	ACC GIVE ME THE LAST WINDOW OPENED ID    
}

What I want is find the ID of the very last window opened, but I don't have any info about this window because this window will only exist after a click, so after the click that window will be the last one opened, and I want get the ID of it.

There's a way to do this?
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: Acc library (MSAA) and AccViewer download links

21 Jun 2022, 15:40

Is there any way to get the basic "AccViewer" example to work upon a mouse click (or possibly ignore the mouse click)? It seems that the code ONLY works if it executes while hovering, but by left clicking it changes what values you get in vOutput.
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: Acc library (MSAA) and AccViewer download links

22 Jun 2022, 08:06

My apologies, the issue isn't left clicking messing up the vAcc___- values, the problem is some windows simply return wrong values. So for insqance, Windows Explorer doesn't seem to ever return the correct values for Min/Max/Close buttons if you trigger vOutput with LButton. However, the hover and trigger vOutput with q:: seems to ALWAYS work with these buttons.

So basically I'm really confused as to what is going on in trying to use this library with certain windows + Lbutton trigger. Task Manager is another incorrect one btw.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Acc library (MSAA) and AccViewer download links

22 Jun 2022, 23:44

Which version do you use? I recommend this one.
Skrell
Posts: 302
Joined: 23 Jan 2014, 12:05

Re: Acc library (MSAA) and AccViewer download links

23 Jun 2022, 07:52

rommmcek wrote:
22 Jun 2022, 23:44
Which version do you use? I recommend this one.
This version does in fact seem better, but there's a LOT in this script so I'm not sure how to extract the functions I need in order to write my own script that gathers all the Acc data into variables upon left clicking a button. Can you provide any help with this?

Also, I don't think Acc works well with Windows Apps? Is that correct? It seems like it can only find the titlebar, but can't find the min/max/close caption buttons. For instance, try it on Calc or Edge.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Acc library (MSAA) and AccViewer download links

23 Jun 2022, 19:32

For Name: ControlId for EditControl in GUI is defined by vAccName in Gui, Add, Edit, x%_offset2% y180 w%_fullW% h20 vAccName.
Now when exploring window's elements (w/ mouse hovering) the function GetAccInfo() is being triggered periodically.
For Accessible info function Acc_ObjectFromPoint(ChildId) assigns Acc
Afterwards function UpdateAccInfo(Acc, ChildId, Obj_Path="") is called updating NameEdit Control via GuiControl, , AccName, % Stored.Name:= Acc.accName(ChildId).
Just follow the code flow!

Min, restore/max, close work fine:
Spoiler
Calculating is trickier because paths change when any operator is being applied and reset by C/Esc, but always correctly displayed by Viewer. So its not nice, but not entirely impossible.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 81 guests