set value to Acc object children? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

set value to Acc object children?

07 Aug 2017, 00:05

Hi all,
A text box in some window is my target. The following code pops up the correct message text, meaning Acc part is correct.

Code: Select all

#SingleInstance force
#include Acc.ahk

WinGet,hWnd,id, SOMETITLE
window := Acc_ObjectFromWindow(hWnd) 
children := Acc_Children(window) 
MsgBox % children[11].accValue(0) 
But then, I added one more line: acc.children[11].accValue(0) := "new.mp4" (or: children[11].accValue(0) := "new.mp4")
Nothing happened.
How can I set a new value?

Thanks.
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

08 Aug 2017, 21:41

Or, is it possible to focus on this text box object?
Elgin
Posts: 110
Joined: 30 Sep 2013, 09:19

Re: set value to Acc object children?

09 Aug 2017, 04:28

Hi!

Depending on the type of edit-control, accValue is most likely implemented as read-only. There's no "set_accValue" defined:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

You can (usually...) set the focus to the control by calling "accSelect" with the flag SELFLAG_TAKEFOCUS (0x1):
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Untested:

Code: Select all

children[11].accSelect(0x1,0)
Then you can use SendInput or whatever you like to set the new text.
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

09 Aug 2017, 05:09

Elgin wrote:Hi!

Depending on the type of edit-control, accValue is most likely implemented as read-only. There's no "set_accValue" defined:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

You can (usually...) set the focus to the control by calling "accSelect" with the flag SELFLAG_TAKEFOCUS (0x1):
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Untested:

Code: Select all

children[11].accSelect(0x1,0)
Then you can use SendInput or whatever you like to set the new text.
Thanks for your help.
Today somebody told me, and I found out the full path of this object should be "4,11",instead. So, how am I supposed to write this line "children[11].accSelect(0x1,0)" ?
Elgin
Posts: 110
Joined: 30 Sep 2013, 09:19

Re: set value to Acc object children?

09 Aug 2017, 05:54

"Path", "4, 11"? Is that something specific to "acc.ahk" (which I don't use)?

If it refers to the position in the tree: Root -> Child no. 4 -> Child no. 11 then your code would probably have to look like this:

Code: Select all

#SingleInstance force
#include Acc.ahk

WinGet,hWnd,id, SOMETITLE
window := Acc_ObjectFromWindow(hWnd) 
children := Acc_Children(window) 
grandchildren := Acc_Children(children[4])
grandchildren[11].accSelect(0x1,0)
MsgBox % grandchildren[11].accValue(0) 
Again untested.
User avatar
jeeswg
Posts: 6122
Joined: 19 Dec 2016, 01:58
Location: UK

Re: set value to Acc object children?

09 Aug 2017, 06:28

This might work:

Code: Select all

oAcc := Acc_Get("Object", "4.11", 0, "ahk_id " hWnd)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

09 Aug 2017, 18:07

Elgin wrote:"Path", "4, 11"? Is that something specific to "acc.ahk" (which I don't use)?

Code: Select all

#SingleInstance force
#include Acc.ahk

WinGet,hWnd,id, SOMETITLE
window := Acc_ObjectFromWindow(hWnd) 
children := Acc_Children(window) 
grandchildren := Acc_Children(children[4])
grandchildren[11].accSelect(0x1,0)
MsgBox % grandchildren[11].accValue(0) 
Again untested.
This one returns empty value.

As for the path, both the following codes work, but then the accSelect(0x1,0) part still not working.

Code: Select all

WinGet,hWnd,id, SOMETITLE
window := Acc_ObjectFromWindow(hWnd) 
children := Acc_Children(window) 
Msgbox, % children[11].accValue(0) 

Code: Select all

acc := Acc_Get("Object", "4,11", 0, "SOMETITLE")
MsgBox, % acc.accValue(0)
Elgin
Posts: 110
Joined: 30 Sep 2013, 09:19

Re: set value to Acc object children?

10 Aug 2017, 01:46

Hi again.

This bugged me, so I downloaded acc.ahk from here (so we're sure we're talking about the same thing...):
https://github.com/Drugoy/Autohotkey-sc ... es/Acc.ahk

On a freshly started Win10 File Explorer instance (to make sure the window title is "File Explorer") this code:

Code: Select all

#SingleInstance force
#include Acc.ahk

WinGet,hWnd,id, File Explorer
oAcc := Acc_Get("Object", "4.5.4.1.4.9.4.1.4.1.4.1.4.1", 0, "ahk_id " hWnd) ; selects the Search Quick Access edit field
MsgBox % Acc_Role(oAcc) "; " Acc_State(oAcc) ; should read "editable text; focusable" if the above went well
WinActivate, File Explorer
oAcc.accSelect(0x1,0)
SendInput, New.mp3
Sleep, 100
MsgBox, % oAcc.accValue(0) ; should read "New.mp3"
puts the focus in the Search Quick Access edit field, enters new text and displays the new value.

Have you confirmed the path to the control you want in AccViewer?
tmplinshi
Posts: 1311
Joined: 01 Oct 2013, 14:57

Re: set value to Acc object children?

10 Aug 2017, 05:09

For others who want to test this, the program he mentioned was flareget.

Image

Code: Select all

acc := acc_get("Object", "4.11", 0, "New Download")
MsgBox, % Acc_GetRoleText( acc.accRole(0) )
MsgBox, % acc.accValue(0) ; works
acc.accValue(0) := "New Value" ; failed
Not sure if this is a bug in Acc.ahk, or just that element doesn't support setting values.

Anyway here is a working code using "set focus" and "ControlSend":

Code: Select all

acc := acc_get("Object", "4.11", 0, "New Download")
acc.accDoDefaultAction(0) ; Set Focus
ControlSend,, ^a ; Select All
ControlSendRaw,, New_Value_Here
User avatar
tank
Posts: 2650
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: set value to Acc object children?

10 Aug 2017, 08:52

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Thanks Tank :thumbup:
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

11 Aug 2017, 16:58

Elgin wrote:Hi again.

This bugged me, so I downloaded acc.ahk from here (so we're sure we're talking about the same thing...):
https://github.com/Drugoy/Autohotkey-sc ... es/Acc.ahk

On a freshly started Win10 File Explorer instance (to make sure the window title is "File Explorer") this code:

Code: Select all

#SingleInstance force
#include Acc.ahk

WinGet,hWnd,id, File Explorer
oAcc := Acc_Get("Object", "4.5.4.1.4.9.4.1.4.1.4.1.4.1", 0, "ahk_id " hWnd) ; selects the Search Quick Access edit field
MsgBox % Acc_Role(oAcc) "; " Acc_State(oAcc) ; should read "editable text; focusable" if the above went well
WinActivate, File Explorer
oAcc.accSelect(0x1,0)
SendInput, New.mp3
Sleep, 100
MsgBox, % oAcc.accValue(0) ; should read "New.mp3"
puts the focus in the Search Quick Access edit field, enters new text and displays the new value.

Have you confirmed the path to the control you want in AccViewer?
Thanks again and sorry for the delay, I did not get thread update email notification the last two days.
Just tried your code with this flareget software, it set focus on another edit field "URL"(as shown in tmplinshi's picture), sent "new.mp3", and the last msgbox read empty value.
Seems this software is a little weird. And tmplinshi's method proved fine. Also someone else told me a method, with Acc_Get("Location"...)...controlclick..., which proved fine.
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

11 Aug 2017, 17:03

tmplinshi wrote: Not sure if this is a bug in Acc.ahk, or just that element doesn't support setting values.

Anyway here is a working code using "set focus" and "ControlSend":

Code: Select all

acc := acc_get("Object", "4.11", 0, "New Download")
acc.accDoDefaultAction(0) ; Set Focus
ControlSend,, ^a ; Select All
ControlSendRaw,, New_Value_Here
Perfect and simple!
I did noticed this as in the following picture, thinking maybe I could do something, this is it!
acc3.png
acc3.png (21 KiB) Viewed 1914 times
Thank you for your help!
DRocks
Posts: 441
Joined: 08 May 2018, 10:20

Re: set value to Acc object children?  Topic is solved

09 Nov 2018, 16:50

I've been struggling to get this to work for about a year. Was discouraged and gave up. But I tried now with more knowledge and intuition using AHK to finally get a result.

Code: Select all

	!q:: ; acc viewer / acc.ahk test
	CumulNN:= "WindowsForms10.Window.8.app.0." SageWinClassPattern "_r38_ad17"
	ControlGet,hCtl, HWND,, %CumulNN%, Chèques de paie
		 ;Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
	oAcc:= acc_get("Object", "4.2.6", 0, "ahk_id " hCtl)
	MsgBox, % oAcc.accValue(0)
	return
This is able to get a precise value that is not seen by Window Spy.

I need to:

1. get the Control's Hwnd[/b ] using its ClassNN 1st.
2. get the path of that control with Acc Viewer wihich reveals 2.6 when focusing the cross directly onto the wanted control... 2.6 is not enough because it is relative to another container for this control.
3. get the path of the container above the control's path which is 4
4. sum it up to 4.2.6 as the childPath and it will find the value

Thanks to JeeSwg
joshatt
Posts: 91
Joined: 07 Dec 2014, 08:41
Facebook: joshatt
Google: joshatt

Re: set value to Acc object children?

23 Dec 2018, 19:14

DRocks wrote:
09 Nov 2018, 16:50
I've been struggling to get this to work for about a year. Was discouraged and gave up. But I tried now with more knowledge and intuition using AHK to finally get a result.

Code: Select all

	!q:: ; acc viewer / acc.ahk test
	CumulNN:= "WindowsForms10.Window.8.app.0." SageWinClassPattern "_r38_ad17"
	ControlGet,hCtl, HWND,, %CumulNN%, Chèques de paie
		 ;Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
	oAcc:= acc_get("Object", "4.2.6", 0, "ahk_id " hCtl)
	MsgBox, % oAcc.accValue(0)
	return
This is able to get a precise value that is not seen by Window Spy.

I need to:

1. get the Control's Hwnd[/b ] using its ClassNN 1st.
2. get the path of that control with Acc Viewer wihich reveals 2.6 when focusing the cross directly onto the wanted control... 2.6 is not enough because it is relative to another container for this control.
3. get the path of the container above the control's path which is 4
4. sum it up to 4.2.6 as the childPath and it will find the value

Thanks to JeeSwg


Thanks for your help, and sorry, haven't been back for a long time. I'll try with your code.

Return to “Ask For Help”

Who is online

Users browsing this forum: 1100++ and 231 guests