- Hmm, so you're testing the GUI element under the cursor in Firefox, on Google's input field. Hovering over it, with it either active or inactive. I got similar results to you, although it was inconsistent, getting 'Search' for the first one sometimes, sometimes nothing, and always nothing for the second one.
- Based on this test script, only sometimes does an Acc object have an accFocus object or value.
- It seems plausible to suppose that you could start at an Acc object for a window, and use accFocus all the way down until you get to the focused GUI element, however, based on my tests, only some elements in the hierarchy returned an Acc object or value.
- I did not know what I should expect when performing accFocus on an object, although I've provided two links below for reference. I only use accFocus myself on controls such as listview controls, to identify the index of the focused item. Cheers.
Code: Select all
;[JEE_AccGetPath and JEE_AccGetEnumIndex functions]
;How to get the full ACC path for control on cursor? - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=56470&p=254902#p254902
q:: ;test accFocus - only sometimes does an Acc object have an accFocus object/value
WinGet, hWnd, ID, A
oAcc1 := Acc_ObjectFromPoint()
vAccPath1 := JEE_AccGetPath(oAcc1, hWnd)
oAcc2 := Acc_ObjectFromWindow(hWnd)
vAccPath2 := JEE_AccGetPath(oAcc2, hWnd)
MsgBox, % vAccPath1 "`r`n" vAccPath2
vAccPath := ""
Loop, Parse, vAccPath1, % "."
{
vAccPath .= (A_Index=1?"":".") A_LoopField
oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
MsgBox, % vAccPath "`r`n" "accFocus is object: " IsObject(oAcc.accFocus) "`r`n" "accFocus value: " oAcc.accFocus "`r`n" "accName: " oAcc.accName(0) "`r`n" "accValue: " oAcc.accValue(0)
}
return
- Links:
IAccessible.accFocus Property (Accessibility) | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet ... work-4.7.2
IAccessible::get_accFocus | Microsoft Docs
https://docs.microsoft.com/en-gb/window ... t_accfocus