set text/state of listbox/listview items via Acc? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 5290
Joined: 19 Dec 2016, 01:58
Location: UK

set text/state of listbox/listview items via Acc?

02 Jan 2017, 00:31

Is it possible via the Acc library, or some other method already existing, to set the text/status (status e.g. selected) for listbox items/listview items, or the ticked status for buttons? Otherwise it will have be the PostMessage/SendMessage route (which I already have functions for).

e.g.

Code: Select all

ControlGet, hCtl, Hwnd, , ListBox1, A
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl)
MsgBox % oAcc.accName(4)
oAcc.accName(4) := "hello" ;does nothing

ControlGet, hCtl, Hwnd, , Button2, A
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl)
MsgBox % oAcc.accState
oAcc.accState := 1048724 ;causes error
[EDIT: an example that does work]

Code: Select all

ControlGet, hCtl, Hwnd, , Edit1, A
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl)
MsgBox % oAcc.accValue
oAcc.accValue := "hello" ;this does work
Last edited by jeeswg on 02 Jan 2017, 10:16, edited 2 times in total.
just me
Posts: 5581
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: set text of listbox/listview items via Acc?

02 Jan 2017, 04:57

For selection see IAccessible interface.
User avatar
jeeswg
Posts: 5290
Joined: 19 Dec 2016, 01:58
Location: UK

Re: set text/state of listbox/listview items via Acc?

02 Jan 2017, 12:34

Looking at the response I was thinking in my head something along the lines of:
'How can I make a program in C++.'
'Google C++.'

This link is actually immensely helpful, basically gives me everything I need,
thanks. One query is if there is some alternative to 'accDoDefaultAction'
like 'do non-default action', or 'do action number 3'.
User avatar
jeeswg
Posts: 5290
Joined: 19 Dec 2016, 01:58
Location: UK

Re: set text/state of listbox/listview items via Acc?  Topic is solved

02 Jan 2017, 13:01

As regards setting text:
- accName is read-only, but accValue isn't.

As regards setting state:
- accFocus/accSelection/accState are read-only, but accSelect can change the focus/selection.
- The state of button controls can be changed by doing it's default action: check/uncheck.
- I'm still unsure if Acc can check/uncheck menu items (if not, I can use SetMenuItemInfo).

Some further unrelated points:
- accHitTest, might be an alternative to WM_NCHITTEST.
- accDefaultAction, 'A string that describes the object's default action.'
bodosko
Posts: 13
Joined: 05 May 2017, 10:49

Re: set text/state of listbox/listview items via Acc?

24 May 2017, 13:35

For me the accValue is not working on a specific window.
I already used it to change values of Windows own windows (lol), but now I'm trying to change value of a input text in Firefox and it's not working.

Code: Select all

	WinGet, hWnd, ID, A
	oAcc := Acc_Get("Object", "4.20.1.1.1.3.1.1.1.1.2.2.1.1.1.1.1.11", 0, "ahk_id " hWnd)
	oAcc.accDoDefaultAction(0) ;works

	oAcc := Acc_Get("Object", "4.20.1.1.1.3.1.1.1.1.3.2.1.1.2", 0, "ahk_id " hWnd)
	oAcc.accDoDefaultAction(0) ;works

	oAcc := Acc_Get("Object", "4.20.1.1.1.3.1.1.2.1.4.2.1", 0, "ahk_id " hWnd)
	MsgBox, % oAcc.accValue(0) ;works
	oAcc.accValue := "hello"   ;error: accValue not implemented
User avatar
jeeswg
Posts: 5290
Joined: 19 Dec 2016, 01:58
Location: UK

Re: set text/state of listbox/listview items via Acc?

27 May 2017, 19:07

Yes, Acc cannot always set the value of a control/element. But that doesn't mean that there isn't another way to change the value.

You could start a new thread on Ask For Help, asking about how to change a webpage element's text in Firefox, possibly via Selenium, a program which I haven't tried myself. Otherwise you could use IE and COM.

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, chngrcn, Google [Bot] and 57 guests