jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

Helpful script writing tricks and HowTo's
julesverne
Posts: 13
Joined: 18 Apr 2017, 14:39
GitHub: JulesverneOnGitHub

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

03 Aug 2019, 13:10

I'm not sure how, but I figured it out, it's working. I think the biggest hurdle I faced was where you were coming up with the ACCpath numbers (using your Notepad example I was finally able to understand). A couple things I couldn't figure out still was how does a child path work into the function below, in addition what is parameter 3 and is it always 0?

Code: Select all

oAcc := Acc_Get("Object", "1.30", 0, "ahk_id " hCtl)
Also, thanks again! Acc Rules!!
User avatar
jeeswg
Posts: 6829
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

03 Aug 2019, 13:45

- Acc_Get's ChildID parameter is sometimes used to specify a subitem, e.g. 0 for the listview, a positive integer for a specific listview item.
- I use JEE_AccGetTextAll to determine Acc_Get's ChildPath parameter, it may also be possible to derive this via AccViewer's status bar. Each number in the path refers to the nth child of an object.
- Btw do always try AHK's window spy first, some things can be done via ClassNNs and ControlGetText/other ControlXXX commands/functions. [EDIT: I've added some text re. the Acc path and re. controls to the first post of this thread.]
Last edited by jeeswg on 16 Aug 2019, 13:17, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
blue83
Posts: 48
Joined: 11 Apr 2018, 06:38

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

06 Aug 2019, 02:56

Hi jeeswg,

I can not get "JEE_AccGetTextAll" to work.

Can you give me an example of a script with some app.

Dont know what to include, how to do it in a way that at the end MsgBox show me what it should.

Thank you.
User avatar
jeeswg
Posts: 6829
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

10 Aug 2019, 18:06

Some pointers on using JEE_AccGetTextAll.
Note: it can be quite slow, because there may be a lot of GUI elements to loop through.
I generally use it for diagnostic purposes to get info on a window, and typically use Acc_Get in everyday scripts.

Code: Select all

;add an #Include line e.g.:
;#Include Acc.ahk
;#Include C:\MyDir\Acc.ahk

;or don't use #Include, but instead:
;copy Acc.ahk to an appropriate Lib folder:
;Functions - Definition & Usage | AutoHotkey
;https://www.autohotkey.com/docs/Functions.htm#lib
;%A_ScriptDir%\Lib\  ; Local library - requires [v1.0.90+].
;%A_MyDocuments%\AutoHotkey\Lib\  ; User library.
;directory-of-the-currently-running-AutoHotkey.exe\Lib\  ; Standard library.

q:: ;get text and Acc paths for GUI elements
WinGet, hWnd, ID, A
Clipboard := JEE_AccGetTextAll(hWnd, "`r`n")
MsgBox, % "done"
return

;paste the 'JEE_AccGetTextAll' function somewhere in the script
;(it can be above or below the code where it's used)
;available at these 2 links:
;GUIs via DllCall: get/set internal/external control text - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=40514
;Acc: get text from all window/control elements - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=40615
;JEE_AccGetTextAll(...)
;{
;...
;}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
blue83
Posts: 48
Joined: 11 Apr 2018, 06:38

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

12 Aug 2019, 01:58

Hi jeeswg,

Yes ofcourse, you just open my eyes, I was so close to final result.

Thank you on clarification.
AHKStudent
Posts: 595
Joined: 05 May 2018, 12:23

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

09 Nov 2019, 18:01

"accLocation: can be used to output ByRef a GUI element's coordinates"

Hi Jeeswg

Do you have a sample of this? gsvidip.accLocation(0) (what to place as parameters instead of the 0?)

Thanks
User avatar
jeeswg
Posts: 6829
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA)

09 Nov 2019, 18:16

From Acc.ahk:

Code: Select all

Acc_Location(Acc, ChildId=0, byref Position="") { ; adapted from Sean's code
	try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
	catch
		return
	Position := "x" NumGet(x,0,"int") " y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")
	return	{x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")}
}
There are alternative versions of Acc.ahk in rbrtryn_3-04-2014.7z:
Index of /joe_df/autohotkey_scripts_archive
https://www.autohotkey.com/joe_df/autohotkey_scripts_archive/

Code: Select all

;~Sean\Lib\Acc.ahk
Acc_Location(Acc, ChildId=0) { ; adapted from Sean's code
	try Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
	catch
		return
	return	{x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")
		,	pos:"x" NumGet(x,0,"int")" y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")}
}

;~jethrow\Acc.ahk
Acc_Location(Acc, ChildId=0) { ; adapted from Sean's code
	try Acc.accLocation(ComObj(0x4003, & x := 0)
	                  , ComObj(0x4003,&y:=0)
					  , ComObj(0x4003,&w:=0)
					  , ComObj(0x4003,&h:=0)
					  , ChildId)
	catch
		return
	return { x:NumGet(x,0,"int")
	       , y:NumGet(y,0,"int")
		   , w:NumGet(w,0,"int")
		   , h:NumGet(h,0,"int")
		   , pos:"x" NumGet(x,0,"int")
		      . " y" NumGet(y,0,"int")
			  . " w" NumGet(w,0,"int")
			  . " h" NumGet(h,0,"int") }
}
Last edited by jeeswg on 10 Nov 2019, 06:00, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 7 guests