Here is a sample code. It'll stop at level one, i.e., no recursion into children of children.
Please test it while firefox is running.
CoInitialize()
hModule := DllCall("LoadLibrary", "str", "oleacc")
hWnd := WinExist("ahk_class MozillaUIWindowClass")
DllCall("oleacc\AccessibleObjectFromWindow", "Uint", hWnd, "Uint", 0, "Uint", GUID4String(IID_IAccessible,"{618736E0-3C3D-11CF-810C-00AA00389B71}"), "UintP", pacc)
MsgBox, % "<Parent>`n"
. "Children:`t" . (nCount:=AccessibleChildren(pacc, varChildren)) . "`n"
. "Name:`t`t" . Invoke(pacc, "accName") . "`n"
. "Role:`t`t" . GetRoleText(Invoke(pacc, "accRole")) . "`n"
. "State:`t`t" . GetStateText(Invoke(pacc, "accState")) . "`n"
. "Description:`t" . Invoke(pacc, "accDescription") . "`n"
. "Value:`t`t" . Invoke(pacc, "accValue") . "`n"
. "Help:`t`t" . Invoke(pacc, "accHelp") . "`n"
. "Keyboard:`t" . Invoke(pacc, "accKeyboardShortcut") . "`n"
. "DefAction:`t" . Invoke(pacc, "accDefaultAction") . "`n"
Loop, %nCount%
MsgBox, % "Children:`t" . Invoke(paccChild:=NumGet(varChildren,16*(A_Index-1),"Ushort")=9 ? NumGet(varChildren,16*(A_Index-1)+8) : Invoke(pacc, "accChild", NumGet(varChildren,16*(A_Index-1)+8)), "accChildCount") . "`n"
. "Name:`t`t" . Invoke(paccChild, "accName") . "`n"
. "Role:`t`t" . GetRoleText(Invoke(paccChild, "accRole")) . "`n"
. "State:`t`t" . GetStateText(Invoke(paccChild, "accState")) . "`n"
. "Description:`t" . Invoke(paccChild, "accDescription") . "`n"
. "Value:`t`t" . Invoke(paccChild, "accValue") . "`n"
. "Help:`t`t" . Invoke(paccChild, "accHelp") . "`n"
. "Keyboard:`t" . Invoke(paccChild, "accKeyboardShortcut") . "`n"
. "DefAction:`t" . Invoke(paccChild, "accDefaultAction") . "`n"
, Release(paccChild)
Release(pacc)
DllCall("FreeLibrary", "Uint", hModule)
CoUninitialize()
AccessibleChildren(paccContainer, ByRef varChildren)
{
cChildren := Invoke(paccContainer, "accChildCount")
VarSetCapacity(varChildren, 16*cChildren, 0)
DllCall("oleacc\AccessibleChildren", "Uint", paccContainer, "int", 0, "int", cChildren, "Uint", &varChildren, "intP", cObtained)
Return cObtained
}
GetRoleText(nRole)
{
nSize := DllCall("oleacc\GetRoleTextA", "Uint", nRole, "Uint", 0, "Uint", 0)
VarSetCapacity(sRole, nSize)
DllCall("oleacc\GetRoleTextA", "Uint", nRole, "str", sRole, "Uint", nSize+1)
Return sRole
}
GetStateText(nState)
{
nSize := DllCall("oleacc\GetStateTextA", "Uint", nState, "Uint", 0, "Uint", 0)
VarSetCapacity(sState, nSize)
DllCall("oleacc\GetStateTextA", "Uint", nState, "str", sState, "Uint", nSize+1)
Return sState
}
#Include CoHelper.ahk
PS. I deliberately omitted a few which are using VT_BYREF parameters, as have to use Invoke_() for these.
MsgBox, % Invoke_(pacc, "accHelpTopic", 0x4008, "") . ":`t" . _TEMP_VT_BYREF_1
Invoke_(pacc, "accLocation", 0x4003, 0, 0x4003, 0, 0x4003, 0, 0x4003, 0)
MsgBox, % "(l,t,w,h):`t" . "(" . _TEMP_VT_BYREF_1<<32>>32 . "," . _TEMP_VT_BYREF_2<<32>>32 . "," . _TEMP_VT_BYREF_3 . "," . _TEMP_VT_BYREF_4 . ")"
The
accLocation returns Left, Top, Width, Height. OTOH, Access Explorer converts them to Left, Top, Right, Bottom.