Having trouble getting accSelect to work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
casperharkin
Posts: 11
Joined: 27 Sep 2017, 20:52

Having trouble getting accSelect to work

19 Jul 2019, 00:33

Hi all,

Can I please have someone help me understand why I cant select an edit control, then select another using ACC.

Code: Select all

WinGet,hWnd,id, Accounts Receivable (Production)

oAcc := Acc_Get("Object", "4.4.4.1.4.6.4.6.4.1.4.6.4", 0, "ahk_id " hWnd) ; selects Amount Control in AR 
oAcc.accSelect(0x1,0)
SendInput, $1007
;oAcc.accSelect(0x1,3) ; Trying to deselect it first, no luck
;oAcc.accSelect(3) ; Trying to deselect it first, no luck
;oAcc.accSelect(3,0) ; Trying to deselect it first, no luck
;oAcc := ; Trying to reset it, no luck

sleep 500

oAcc := Acc_Get("Object", "4.4.4.1.4.6.4.6.4.1.4.16.4", 0, "ahk_id " hWnd) ; selects Description Control in AR 
oAcc.accSelect(0x1,0)
SendInput, SALARY OVERPAYMENT
It will work if I am just selecting and sending text to a single control, both Amount and Description work, but I cant seem to do the next one. Anyone able to point me in the right direction?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Having trouble getting accSelect to work  Topic is solved

19 Jul 2019, 00:46

- I usually think of accSelect in relation to items *within* controls e.g. listview controls.
- To focus a control, I would use ControlFocus.
- You can get the control hWnd for an Acc object via Acc_WindowFromObject, and pass that to ControlFocus.

- There's a difference between controls and elements. E.g. the word 'element' is used here:
IAccessible (oleacc.h) | Microsoft Docs
https://docs.microsoft.com/en-gb/windows/win32/api/oleacc/nn-oleacc-iaccessible
- You can list controls via WinGet ControlList, whereas there may be many many more elements.
- See JEE_AccGetTextAll to list elements:
jeeswg's Acc tutorial (Microsoft Active Accessibility) (MSAA) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=40590
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
casperharkin
Posts: 11
Joined: 27 Sep 2017, 20:52

Re: Having trouble getting accSelect to work

19 Jul 2019, 01:06

Thank you Jeeswg, Acc_WindowFromObject to get hWnd is exactly what I was looking for. The controls ClassNN in this application change every time I started it, and I was looking for a way to get around that.

Code: Select all

WinGet,hWnd,id, Accounts Receivable (Production)

oAcc := Acc_Get("Object", "4.4.4.1.4.6.4.6.4.1.4.6.4", 0, "ahk_id " hWnd) ; selects the Search Quick Access edit field
ControlHwnd := Acc_WindowFromObject(oAcc)
ControlFocus,, ahk_id %ControlHwnd%
SendInput, $1007

oAcc := Acc_Get("Object", "4.4.4.1.4.6.4.6.4.1.4.16.4", 0, "ahk_id " hWnd) ; selects the Search Quick Access edit field
ControlHwnd := Acc_WindowFromObject(oAcc)
ControlFocus,, ahk_id %ControlHwnd%
SendInput, Salary Overpayment

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Theda, w_i_k_i_d and 267 guests