I got errors in Acc_GetRoleText(nRole) when using your v2 Acc version on a Firefox window.
The cause: the nRole parameter expects an integer (an object role constant) but in Firefox it was sometimes a string like "div", "span", "h2" (HTML tag name). The nRole value is set by Acc.accRole(ChildId) in Acc_Role(). I don't know what causes it to be a string sometimes but a workaround for your v2 Acc is to add these two lines. The role text in such cases then becomes "Unknown object", which in my tests is also what v1 Acc.ahk outputs in this case.
Code: Select all
Acc_GetRoleText(nRole)
{
if !IsInteger(nRole)
nRole := 0
;MsgBox(nRole), nRole := 0 ;notify if nRole is string (for testing)
https://docs.microsoft.com/en-us/windows/win32/winauto/object-roles
If further investigation into this shows that "Unknown object" is a plausible role text in case nRole is a string then we can simply return it early
Code: Select all
if !IsInteger(nRole)
return "Unknown object"