How do I click and edit text fields in apps using Acc Libraries?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 01 Apr 2022, 14:51

I was able to make one script with autohotkey already, but it uses a long-winded series of SendInputs commands to manually move the mouse around and click on text fields.

I want to figure out how to use the Acc Library to click specific text fields and enter new values.

My problem is there is no solid ABSOLUTE BEGINNER friendly explanation on how to pull off such a simple task. I spent the entire day searching the autohotkey forum and found nothing that amply explained how it worked. I searched google as well, and got nothing helpful in other autohotkey site; and I searched YouTube for any tutorials that could help, but alas, El Zilcho

I need autohotkey to go into Davinci Resolve (free and beefy edition) and select a text field in the inspector window, specifically the zoom text field for instance, using the Acc Library.
Screenshot (158).png
Screenshot (158).png (43.65 KiB) Viewed 2363 times
I cannot figure out how to even begin going about it. I used the Accessible Info Viewer to find specific identifying properties to find the text fields, but then I immediately hit a brick wall when it came to:

1. Selecting the text field, and then
2. Interacting with it, namely double clicking the text field and replacing the current value with value
Screenshot (157).png
Screenshot (157).png (22.64 KiB) Viewed 2363 times
I tried my best to find anything that would help for the task, but couldn't find any pertinent info. I really am sorry if I seem incompetent, I genuinely couldn't find anything beginner-friendly to get even an iota of how that stuff works. I'm sorry :(

[Mod action: Moved from “Scripts and Functions”]

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 01 Apr 2022, 16:02

I'm not an expert in Acc, but here is a tutorial in case it helps. viewtopic.php?p=272465

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 01 Apr 2022, 18:43

mikeyww wrote:
01 Apr 2022, 16:02
I'm not an expert in Acc, but here is a tutorial in case it helps. viewtopic.php?p=272465
Yeah I saw this a bunch but it only makes you aware of what is possible, not so much on execution though

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 01 Apr 2022, 19:48

The basic idea is that once you have identified the right "tree path", you can execute various commands or actions. I would dive into some of the links & examples, especially for JEE_AccGetTextAll, which you can call, and AccViewer Basic. You could also search the forum for accValue and accDoDefaultAction, as you may find additional examples related to your goal. If you search for Chrome Acc, you may find more examples there of how to get various information from Chrome, and you may be able to adapt some of the approaches.

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 02 Apr 2022, 12:31

mikeyww wrote:
01 Apr 2022, 19:48
The basic idea is that once you have identified the right "tree path", you can execute various commands or actions. I would dive into some of the links & examples, especially for JEE_AccGetTextAll, which you can call, and AccViewer Basic. You could also search the forum for accValue and accDoDefaultAction, as you may find additional examples related to your goal. If you search for Chrome Acc, you may find more examples there of how to get various information from Chrome, and you may be able to adapt some of the approaches.
I'll get to digging; thanks for the leads! BRB with any finds.

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 02 Apr 2022, 15:46

The most I could cobble together thus far:

Code: Select all

#+j:: 
WinGet, hWnd, ID, A
vAcc := Acc_Get("Object", "4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1", 0, "ahk_id" hWnd)
%vAcc%.accDoDefaultAction(0)
return
I found code that identified the current window and read back the value of an Object path, so I thought "create a variable that contains the location of the zoom text box"
From there, call the variable and envoke what I thought was a function to enact the action of said object.
To reiterate, I need to enter a new value in the zoom box. Manually, you double click it and enter a value. I've already made a script that does this with SendInput commannds but,
I want to be able to accomplish this effect with out absolutely needing panels to be in specific positions prior to activating the hotkey.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by BoBo » 02 Apr 2022, 15:59

Would you mind leaving of what Chrome/Edge release that path ID is? Thx :)

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 02 Apr 2022, 17:21

I'm working on a video editor actually. Not a browser

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 02 Apr 2022, 18:22

I do not have a way to test this, but you probably should not be using %.

neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by neogna2 » 03 Apr 2022, 02:37

@GimpyGosling I don't have the program you want to control but try this

Code: Select all

WinGet, hWnd, ID, A
vAcc := Acc_Get("Object", "4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1", 0, "ahk_id" hWnd)
vAcc.accValue(0) := "2"    ; set value 2
Setting a value through Acc doesn't work for all elements. If it doesn't work in this case you can as a workaround try to use Acc to click/focus the element and then use Send to set text.

From jeeswg's thread viewtopic.php?p=272465
- Acc provides an accDoDefaultAction method, where available, this is usually equivalent to clicking on a GUI element/control.
- The accSelect method can be used to change the focused/selected items in a control e.g. a listview control.
- For *some* but not all GUI elements, you can set the element's value by specifying the text via accValue.
Another thing to keep in mind is that very long Acc paths like that can be fragile and may change depending on what other controls and panes are shown or hidden in a complex application window. Sometimes using role name text for some nodes in the Acc path helps. Sometimes you need to make the hotkey try a few different Acc paths until the current correct one is found and only then use it.
See viewtopic.php?f=76&t=91393&p=403858#p403858 for some notes.

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 04 Apr 2022, 11:18

@neogna2 I tried out your solution, unfortunately it didn't work either.
So I tried out your other suggestion of identifying the object and then clicking it.

Code: Select all

^F5::
    vAcc := Acc_ObjectFromPath(Acc_ObjectFromWindow(Win), "4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1")
    Location := Acc_Location(vAcc)
    Click, Location, 2
return
Still didn't work, but am I headed in the right direction with this? I'm thinking "create a variable that identifies the text field in question"
then from there "create a variable containing the X,Y coordinates of the prior variable" and then click twice at those coordinates held in "location".
I get an error message saying something is wrong with my declaration of vAcc.

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 04 Apr 2022, 11:34

The location is an array. Below is one example with Chrome.

Code: Select all

#Include d:\utils\acc\Acc.ahk
accPath = 4.1.1.2.1.1.1.1

#IfWinExist ahk_exe chrome.exe
F3::
WinActivate
vAcc := Acc_Get("Object", accPath, 0, "ahk_id" WinExist())
pos  := Acc_Location(vAcc)
MsgBox, 64, Position, % "x = " pos.x "`ny = " pos.y "`nw = " pos.w "`nh = " pos.h
CoordMode, Mouse
MouseMove, pos.x, pos.y
; MouseClick,, pos.x, pos.y
Return
#IfWinExist

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 04 Apr 2022, 13:12

@mikeyww I tried your code out, while it didn't go to the desired location IT DID DO SOMETHING as opposed to nothing before XD We're getting warmer!

Code: Select all

^F11::
    WinActivate
    vAcc := Acc_Get("Object", 4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1, 0, "ahk_id" WinExist())
    pos := Acc_Location(vAcc)
    MsgBox, 64, Position, % "x = " pos.x "`ny = " pos.y "`nw = " pos.w "`nh = " pos.h
    CoordMode, Mouse
    MouseMove, pos.x, pos.y
return
I inserted the code and instead of going to the desired coordinates (1691, 206) it ends up going to (48,48) near the top left. Coordinates are relative to screen
Screenshot (164).png
Screenshot (164).png (762.2 KiB) Viewed 1917 times
I tried altering it by adjusting the Coordmode command to pixel and screen, and neither changed the outcome, still ends up at that top left corner

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 04 Apr 2022, 13:18

You could try something like the following. Of course, if you have the wrong path, then you will get the wrong result!

Code: Select all

#Include d:\utils\acc\Acc.ahk
accPath = 4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1

^F11::
vAcc := Acc_Get("Object", accPath, 0, "ahk_id" WinActive("A"))
pos  := Acc_Location(vAcc)
MsgBox, 64, Position, % "x = " pos.x "`ny = " pos.y "`nw = " pos.w "`nh = " pos.h
CoordMode, Mouse
MouseMove, pos.x, pos.y
Return
Functions use expressions. The following demonstrates the potential issue.

Code: Select all

t = 7.8.9
f(1)       ; Expression
f(1.2.3)   ; Not typically an expression
f("4.5.6") ; Expression
f(t)       ; Expression

f(x) {
 MsgBox #%x%#
}

GimpyGosling
Posts: 12
Joined: 31 Mar 2022, 14:40

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by GimpyGosling » 11 Apr 2022, 13:48

mikeyww wrote:
04 Apr 2022, 13:18
You could try something like the following. Of course, if you have the wrong path, then you will get the wrong result!

Code: Select all

#Include d:\utils\acc\Acc.ahk
accPath = 4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1

^F11::
vAcc := Acc_Get("Object", accPath, 0, "ahk_id" WinActive("A"))
pos  := Acc_Location(vAcc)
MsgBox, 64, Position, % "x = " pos.x "`ny = " pos.y "`nw = " pos.w "`nh = " pos.h
CoordMode, Mouse
MouseMove, pos.x, pos.y
Return
Functions use expressions. The following demonstrates the potential issue.

Code: Select all

t = 7.8.9
f(1)       ; Expression
f(1.2.3)   ; Not typically an expression
f("4.5.6") ; Expression
f(t)       ; Expression

f(x) {
 MsgBox #%x%#
}
Hey dude, sorry for not replying sooner! I tried out the code and it still gives me the same result. I am indeed using the correct path, but what is happening is it's acting as though I were specifying
the incorrect path that's further up the line like 4.2.2.1.1 instead of going all the way through

User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by mikeyww » 11 Apr 2022, 18:18

I don't have a way to test it, but you sometimes need to try various paths before you find the right one.

User avatar
SteveMylo
Posts: 233
Joined: 22 Jun 2021, 00:50
Location: Australia
Contact:

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by SteveMylo » 22 Jun 2022, 00:47

@GimpyGosling Any Luck on this? I'm trying to do the exact same thing in Davinci?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by BoBo » 22 Jun 2022, 01:02

@SteveMylo
BoBo wrote:
02 Apr 2022, 15:59
Would you mind leaving of what Chrome/Edge release that path ID is? Thx :)
This question is key, as using a path that is provided with any script in the forum gets most likely outdated after Chrome/Edge has been updated.
In case you are new to this topic I’d recommend to go with UIA (the successor of ACC, see 'Scripts & Functions' forum section) that is meanwhile more on focus and therefore better supported.

User avatar
SteveMylo
Posts: 233
Joined: 22 Jun 2021, 00:50
Location: Australia
Contact:

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by SteveMylo » 22 Jun 2022, 01:34

BoBo wrote:
22 Jun 2022, 01:02
@SteveMylo
BoBo wrote:
02 Apr 2022, 15:59
Would you mind leaving of what Chrome/Edge release that path ID is? Thx :)
This question is key, as using a path that is provided with any script in the forum gets most likely outdated after Chrome/Edge has been updated.
In case you are new to this topic I’d recommend to go with UIA (the successor of ACC, see 'Scripts & Functions' forum section) that is meanwhile more on focus and therefore better supported.
Yes I actually have just been researching the UAI, it's very good. Thank you for the suggestion.
Keep in mind the Orginal Quesiton has nothing to do with chrome or a Web browser, he/she is talking about Davinci Resolve Video Editing Software. It doesn't get updated very often nor would it even change at all.
It's Something that almost no one knows how to use the ACC library on NOR anything else cause Davinci Resolve hides their controls or whatever and isn't easily accessible if at all. I've been asking this question for a very long time and everyone seems to get stumped. But we are not giving up cause I Know it has to be possible.
I think keeping this thread open is very important.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How do I click and edit text fields in apps using Acc Libraries?

Post by BoBo » 22 Jun 2022, 02:18

Well, was just for the records. So is this, the (AFAICS) updated "AccViewer" that is able to identify acc-paths more reliably, kindly provided by @rommmcek : viewtopic.php?p=382050#p382050 + [Download]

HTH

Post Reply

Return to “Ask for Help (v1)”