- You appear to be doing the right things. Here are some ideas using Notepad's Find dialog as an example:
- I would use accName/accValue/Acc_Location, to check that I've got the right element.
- I would use JEE_AccGetTextAll to list all elements, and to list the correct Acc paths (AccViewer doesn't always give the right path).
- Perhaps you're not clicking on the right element, maybe it should be a different element e.g. an ancestor/sibling/descendant element.
- Possibly you need to use accDoDefaultAction(n), where n is not 0. E.g. a listview item, rather than the listview as a whole.
- As a workaround, if Acc_Location is giving you the right location, you could use MouseClick to click the element, rather than accDoDefaultAction.
Code: Select all
;[JEE_AccGetTextAll function]
;Acc: get text from all window/control elements - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=40615
q:: ;notepad find dialog - get Acc info
WinGet, hWnd, ID, A
Clipboard := JEE_AccGetTextAll(hWnd, "`r`n")
MsgBox, % "done"
return
w:: ;notepad find dialog - toggle 'Match case' checkbox via accDoDefaultAction (and get element info)
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "4.4.4", 0, "ahk_id " hWnd)
oAcc.accDoDefaultAction(0)
oRect := Acc_Location(oAcc)
vEltPos := Format("x{} y{} w{} h{}", oRect.x, oRect.y, oRect.w, oRect.h)
MsgBox, % oAcc.accName(0) "`r`n" oAcc.accValue(0) "`r`n" vEltPos
oAcc := oRect := ""
return
e:: ;notepad find dialog - toggle 'Match case' checkbox via accDoDefaultAction
WinGet, hWnd, ID, A
Acc_Get("DoDefaultAction", "4.4.4", 0, "ahk_id " hWnd)
return
r:: ;notepad find dialog - toggle 'Match case' checkbox via MouseClick
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "4.4.4", 0, "ahk_id " hWnd)
oRect := Acc_Location(oAcc)
CoordMode, Mouse, Screen
vCurX := oRect.x + oRect.w/2
vCurY := oRect.y + oRect.h/2
MouseClick,, % vCurX, % vCurY
oAcc := oRect := ""
return