Page 2 of 2

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

Posted: 27 Sep 2019, 12:17
by potroveio
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!

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

Posted: 28 Sep 2019, 10:43
by burque505
@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

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

Posted: 29 Sep 2019, 20:09
by jeeswg
@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

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

Posted: 23 Oct 2020, 15:30
by unknownascaptain
This is an amazing script, thank you so much for your dedication, jeeswg!
I'm still out of luck trying to access text inside a table of a certain program. Is it guaranteed that if JEE_AccGetTextAll cannot find the text I'm looking for, then no ACC code will?
Just to make sure, I looped through ALL the JEE_AccGetTextAll results from ALL open windows, and the only result I can find is my own text editor where I'm writing the script.
I set vLimN and vLimV to 99999 for the purposes of this test.

Code: Select all

q::
DetectHiddenWindows, On
WinGet windows, List
Loop %windows%
{
	id := windows%A_Index%
	WinGet, hWnd, ID, ahk_id %id%
	WinGetTitle wt, ahk_id %id%
	jee := JEE_AccGetTextAll(hWnd, "`r`n")
	if(InStr(jee, "A PIECE OF TEXT THAT I CAN SEE IN THE GOD-FORSAKEN WINDOW I'M TRYING TO FIND")){
		MsgBox, Found! in %wt% - %hWnd%
		MsgBox, % Clipboard := %jee%
	}
}
MsgBox, All done!