Acc library (MSAA) and AccViewer download links

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Acc library (MSAA) and AccViewer download links

28 Dec 2016, 09:31

- To whom it may concern -
as this thread is from 2016, you might get interested to use UIA , ACC's successor instead: viewtopic.php?f=6&t=104999

"UIAutomation is a Microsoft accessibility framework that allows interacting with user-accessible elements (clicking buttons, sending text etc) in a programmatic way. It is the successor to the Acc/MSAA framework."

... and why that makes even more sense: viewtopic.php?p=467030#p467030
But just in case you stick with ACC, UIAViewer.ahk (provided on the page linked above) offers the option to run in "Acc-Mode" to identify Acc-paths more reliable!

[(BoBo) Moderator: Added 2022-06-10]

; ----------------------------------------------------------------------

I couldn't find a page on the new forum with up-to-date links for the Acc library and AccViewer so I'm posting some here:

See AccPack.zip at the bottom of this post, it contains AHK v1 versions of:
Acc.ahk
AccViewer.ahk
Anchor.ahk
iWB2 Learner UPDATED.ahk

==================================================

[Acc.ahk]
Autohotkey-scripts-.ahk/Acc.ahk at master · Drugoy/Autohotkey-scripts-.ahk · GitHub
https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Acc.ahk

[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

[Anchor.ahk (for use with AccViewer)]
AutoHotkey-Scripts/Anchor.ahk at master · polyethene/AutoHotkey-Scripts · GitHub
https://github.com/polyethene/AutoHotkey-Scripts/blob/master/Anchor.ahk

TO DOWNLOAD:
Go to the right-hand side of the page and right-click Raw.

TO INSTALL:
Place Acc.ahk and Anchor.ahk in the folder:
C:\Program Files\AutoHotkey\Lib

TO RUN:
Double-click AccViewer.ahk.

TO USE:
Drag the crosshair to a window/control/object.
Or hover over a window/control/object and press Ctrl+/.

TIPS ON RETRIEVING TEXT/INFORMATION VIA THE ACC LIBRARY:
jeeswg's Acc tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=40590
AccViewer Basic - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=32039

==================================================

[iWB2 Learner UPDATED.ahk (23,803 bytes)]
New item: iWB2 Learner · Issue #94 · ahkscript/awesome-AutoHotkey · GitHub
https://github.com/ahkscript/awesome-AutoHotkey/issues/94

TO DOWNLOAD:
Go to iWB2 Learner UPDATED.zip and right-click,
or instead, use the direct download link:
https://github.com/ahkscript/awesome-AutoHotkey/files/211139/iWB2.Learner.UPDATED.zip

TO RESOLVE THE ERROR ('Error: Invalid function declaration.'):
[note: this error has already been fixed in the AccPack.zip download below]
Edit the script, replace:
TV_GetDiffCount(p1, p2))
with:
TV_GetDiffCount(p1, p2)

==================================================

[Excel_Get function][new version][doesn't require Acc]
MS-Office-COM-Basics/Excel_Get.ahk at master · ahkon/MS-Office-COM-Basics · GitHub
https://github.com/ahkon/MS-Office-COM-Basics/blob/master/Examples/Excel/Excel_Get.ahk

[Excel_Get function][old version][requires Acc]
excel and com? - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/73940-excel-and-com/#entry469769
Attachments
AccPack.zip
(19.83 KiB) Downloaded 4831 times
Last edited by jeeswg on 14 Apr 2018, 17:41, edited 12 times 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
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Acc library (MSAA) and AccViewer download links

20 Jan 2017, 09:51

Thank you very much for this.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

20 Jan 2017, 10:12

Cheers, an absolute pleasure. And just so everyone knows I did not write these great functions!
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Acc library (MSAA) and AccViewer download links

06 Feb 2017, 18:10

For a copy that works with my 64-bit Win7 box you can try https://dl.dropboxusercontent.com/u/676 ... PDATED.ahk.
I corrected the typo listed above and moved a variable. Please let me know if it doesn't work or the link dies.
Edit: That link is dead due to Dropbox policy changes, but it's apparently irrelevant now. April 30, 2018
Thanks!
burque505
Last edited by burque505 on 30 Apr 2018, 15:46, edited 2 times in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

06 Feb 2017, 19:32

I compared your version with the version I have using WinMerge.
Since I have the corrected the (two brackets) error also,
the only difference was:
;#INCLUDE %A_ScriptDir%\Query.ahk
#INCLUDE %A_ScriptDir%\Anchor.ahk
#INCLUDE %A_ScriptDir%\Acc.ahk

Indeed iWB2 Learner requires Anchor.ahk and Acc.ahk,
this can be done by putting them in
C:\Program Files\AutoHotkey\Lib,
but yes sometimes I include scripts directly using #Include.
Query.ahk is no longer needed, and is correctly commented out.

I don't know which variable you moved, WinMerge did not show
any moved variable.
Thank you for your comments.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Acc library (MSAA) and AccViewer download links

07 Sep 2017, 20:01

Hallo @jeeswg

@jNizM recommended this library to make usable a key on my keyboard that AHK does not natively see. All I can see in forum threads, etc, is GUI related, so I feel lost. Any tips? Or who would know, or how do I learn?

Thanks :wave:
try it and see
...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

07 Sep 2017, 20:29

I haven't personally done anything like that. Not that it's impossible, but I can't see how Acc would help with this, I view it more for interacting with GUIs as you say. Perhaps AHKHID (the word does look a little like 'Acc') or Lua? I'd say more if I knew any more. Best of luck.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

15 Sep 2017, 07:31

I've since investigated AHKHID. Try these scripts in case they help to solve your problem.
NEW Barcode Input Capture (USB and RS232 compatible) - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 73#p170673
AHK keyboard hook + AHKHID causing buggy behavior - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 925#p87925
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Re: Acc library (MSAA) and AccViewer download links

26 Dec 2017, 13:25

For the (others) dummies who(also) struggle to understand the syntax:
https://autohotkey.com/boards/viewtopic ... 72#p190772
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Acc library (MSAA) and AccViewer download links

30 Apr 2018, 12:40

I found that ACC library does not work with directive #if.
1 example - open google chrome, move cursor to address bar, and press f10, f11.
When we press f10 - the result will be wrong.

Code: Select all

#If !test()
f10:: return 
#If
return

f11::test()
return

test()
{
   tooltip % Acc_test(child).accName(child)
}

Acc_test(ByRef _idChild_ = "", x = "", y = "")
{
	Static	h
	If Not	h
		h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
	If	DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}
2 example - open google chrome and press f10.
I get error - "Error 0x8001010D - An outgoing call cannot be made since the application dispatching an input-synchronous call".
If I press f11 - all works OK.

Code: Select all

#If !test()
f10:: return 
#If
return

f11::test()
return


test()
{
   hwndChrome := WinExist("ahk_class Chrome_WidgetWin_1")
   AccChrome := Acc_ObjectFromWindow(hwndChrome)
   AccAddressBar := GetElementByName(AccChrome, "Address and search bar")
   msgbox % AccAddressBar.accValue(0)
}

GetElementByName(AccObj, name) {
   if (AccObj.accName(0) = name)
      return AccObj
   
   for k, v in Acc_Children(AccObj)
      if IsObject(obj := GetElementByName(v, name))
         return obj
}
Is it bug of autohotkey or acc library or I do something wrong?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

04 May 2018, 08:15

- @malcev: I did some tests and got the same results as you, the error message appeared when used with #If but otherwise the function worked.
- Since #If has to be fast, perhaps it's placing certain limits on what functions can do.

Code: Select all

#If oAcc := test()
q::
MsgBox, % oAcc.accValue(0)
return
#If

;Error:  0x8001010D - An outgoing call cannot be made since the application is dispatching an input-synchronous call.
;do e then w
e::
oAcc := test()
MsgBox, % oAcc.accValue(0)
return
#If test2()
w::
MsgBox, % oAcc.accValue(0)
return
#If

r::
ToolTip
return

test()
{
	if !hWnd := WinActive("ahk_class Chrome_WidgetWin_1")
		return
	oAcc := Acc_Get("Object", "4.1.2.2.3.5.2", 0, "ahk_id " hWnd)
	ToolTip, % "TEST: " oAcc.accValue(0)
	if InStr(oAcc.accValue(0), "http")
	|| InStr(oAcc.accValue(0), "www")
		return oAcc
}

test2()
{
	global oAcc
	if !hWnd := WinActive("ahk_class Chrome_WidgetWin_1")
		return
	if InStr(oAcc.accValue(0), "http")
	|| InStr(oAcc.accValue(0), "www")
		return 1
}
[EDIT:] The issue is further discussed here:
#If and ComObjCreate return error 0x8001010D - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=48444
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Acc library (MSAA) and AccViewer download links

27 May 2018, 14:18

Question: Does anyone know where in MSDN it talks about ACC? Curious to read up about it and how windows works within its api for this.

I tried doing acc or other searches but was not successful.

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

Re: Acc library (MSAA) and AccViewer download links

27 May 2018, 14:40

There are some links here:
jeeswg's Acc tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=40590

This is pretty much the only link I've used:
IAccessible interface (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Acc library (MSAA) and AccViewer download links

28 May 2018, 02:59

jeeswg wrote:There are some links here:
jeeswg's Acc tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=40590

This is pretty much the only link I've used:
IAccessible interface (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
That was helpful thank you
Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Re: Acc library (MSAA) and AccViewer download links

12 Jun 2018, 10:51

AccViewer.ahk is not working in my system. I don't really know what it's supposed to do, but probably it's not supposed to crash when I press the Show Acc Structure... Unless I press that button, it does abssolutely nothing

My AHK version is 1.1.29.00

Edit: I have managed to do something, first changing the hotkey to CTRL+P (no idea why CTRL+/ did not work). However, it does not seem to find any difference between two dialog boxes I am using within a page :facepalm:
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

12 Jun 2018, 11:12

- Try v1.1.29.01 or a version before v1.1.29.00.
- If you have any further queries re. the dialog boxes, I would suggest starting a new thread.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Acc library (MSAA) and AccViewer download links

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/0fcb8 ... 8d0d974915

Image
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Acc library (MSAA) and AccViewer download links

11 Oct 2018, 14:23

Nice, I like the changes, thank you.
Regards,
burque505
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc library (MSAA) and AccViewer download links

11 Oct 2018, 14:49

- Nicely done tmplinshi.
- I intend to do a similar AccViewer edit re. states.
- You can see the info I intend to display here. All states, like you've done, as well as a list of the focused and selected item indexes if applicable.
AccViewer Basic - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=32039

- I need to add support for getting the Acc path. I want to make available the Acc path relative to the window and relative to the first available ancestor control, ready to copy and paste for use with Acc_Get, in a similar way to this script:
Acc: get text from all window/control elements - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40615
(It's not always clear what the AccViewer path is relative to, what the starting point is.)
And in a similar way to this script (thanks again tmplinshi):
How to get the full ACC path for control on cursor? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 67#p241267

- I also plan to add hotkeys to show the window/control under the cursor.
- I also intend to convert it to AHK v2.
- I found the AccViewer script really really bad to work with. I would like to overhaul the entire code, while retaining the same outward appearance.
- That and iWB2 Learner are the only scripts I've had problems with converting to AHK v2.

- I also want to fix zoom support in iWB2 Learner, but I was having problems with frames inside frames. The still unresolved problem preventing further work on AccViewer.
Internet Explorer get element under cursor (show borders, show text) (any zoom percentage) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29458
- I've decided to get back to AccViewer before iWB2 Learner, but it's somewhere like 11th to 20th on my AutoHotkey to-do list.

[EDIT:] I've addressed getting the Acc path (and text) for the GUI element under the cursor in the scripts below:
[get the Acc path for the element under the cursor]
How to get the full ACC path for control on cursor? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=56470
[ code to try and get the text for the element under the cursor]
getting a link's URL or the content of a tooltip - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=3918
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 “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Auntiejack56 and 123 guests