Acc: get text from all window/control elements

Post your working scripts, libraries and tools
potroveio
Posts: 8
Joined: 17 Sep 2019, 13:45

Re: Acc: get text from all window/control elements

27 Sep 2019, 12:17

Hi,

is this still working with Chrome 77?


I am trying to run this in order to have total tabs open on Chrome shown on a Message Box:

Code: Select all

JEE_ChromeGetTabCount(hWnd){
	oAcc := Acc_Get("Object", "4.1.2.1.1.1", 0, "ahk_id " hWnd)
	for _, oChild in Acc_Children(oAcc)
	{
		vTabText := oChild.accName(0)
		if !(vTabText == "")
		&& !(vTabText == "New Tab")
			vCount++
	}
	oAcc := oChild := ""
	return vCount
}


^+!a:: 
text1 = JEE_ChromeGetTabCount(hWnd)
MsgBox, %text1%
return

and get this errors:

>"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Users\martinhorst\atnbueno.ahk"
C:\Program Files\AutoHotkey\Lib\Acc.ahk (15) : ==> Duplicate function definition.
Specifically: Acc_Init()
>Exit code: 2 Time: 0.3308

I attach also the whole code, taken from another topic: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3702

what am I doing wrong? please enlighten this newbie! Thanks!
Attachments
atnbueno.ahk
(6.52 KiB) Downloaded 14 times
burque505
Posts: 1053
Joined: 22 Jan 2017, 19:37

Re: Acc: get text from all window/control elements

28 Sep 2019, 10:43

@potrovelo, I got the same error you did with Chrome 77. But it does work with mods as shown in the spoiler.

1) Chances are you already have Acc.ahk someplace the script found it (your LIB folder, most likely, where I myself have it); comment out all the "Acc_*" functions and the "Duplicate function definition" error will go a away. But more errors appear - not to worry, though.
2) As written, you are not grabbing the Hwnd of the browser window. Please try the code below, it works for me (you can comment out the MsgBox in the 'JEE_ChromeGetTabCount(hwnd)' hotkey section, of course).

Let me know if it doesn't work (I am at least getting a tab count, don't know if it's right). :D It won't get the right count if you add a tab after the script is running unless you reload.
Spoiler
Regards,
burque505
User avatar
jeeswg
Posts: 6823
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Acc: get text from all window/control elements

29 Sep 2019, 20:09

@potroveio: I updated the Chrome functions, here:
Firefox/Chrome, get tab names/focus tab - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947&p=294316#p294316
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”

Who is online

Users browsing this forum: arcticir, DRocks, robodesign, XShayanX and 54 guests