Manipulating TreeView Control in AHKv2

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
jiaojiaodubai23
Posts: 6
Joined: 22 Nov 2022, 04:16

Manipulating TreeView Control in AHKv2

Post by jiaojiaodubai23 » 22 Nov 2022, 04:30

I am trying to install Acrobat 2022 with AHKv2. A "SysTreeView32" control appears during the installation process.
I want to expand these nodes in turn and click some of their sub items (these sub items are not check boxes, but an icon that can be clicked. After clicking, it will open a shortcut menu for users to select "Install this item", "Cancel this item" or "Install this item and all its sub items"), However, AHKv2 does not seem to have a built-in function like AutoIt's "ControlTreeview" that allows me to operate such controls.

In the current situation, how can I achieve such a requirement?

User avatar
boiler
Posts: 16930
Joined: 21 Dec 2014, 02:44

Re: Manipulating TreeView Control in AHKv2

Post by boiler » 22 Nov 2022, 06:47

I’ve always had to resort to using ImageSearch to manipulate a TreeView (click “+” signs, scroll until a particular item came into view, etc.). Hopefully someone will be able to show how it can be done more directly, but at least that’s one way that I had made work.

jiaojiaodubai23
Posts: 6
Joined: 22 Nov 2022, 04:16

Re: Manipulating TreeView Control in AHKv2

Post by jiaojiaodubai23 » 23 Nov 2022, 11:15

I finally solved the problem temporarily with the following code and completed the installation of Acrobat DC 2022

Code: Select all

SetMouseDelay(300)
Run("*RunAs " A_ScriptDir "\Adobe Acrobat DC 2022 x64 SP\setup.exe")
tittle := "Adobe Acrobat DC (Continuous) - 设置"
WinWait(tittle)
WinActivate(tittle)
ControlClick("Button4", tittle)
ControlClick("Button5", tittle)
WinWait(tittle, "自定义安装")
; Click to expand the first node
ControlClick("x35 y315",tittle,,,,)
; Click to expand the next node
ControlClick("x150 y235",tittle,,,,)
; Jump to the node I need
loop 22{
    Send("{Down}")
    Sleep(200)
}
; Expand the menu of this node
ControlClick("x118 y480",tittle,,,,)
; Wait for the shortcut menu to expand
Sleep(200)
; Hovering the mouse over the shortcut menu helps keep the shortcut menu displayed
MouseMove(300, 510, 50)
; Select “Apply this item”
; Note that only "MouseClick" can be used here
MouseClick(, 300, 510, 50)
ControlClick("Button5", tittle, "安装(&I)")
WinWait(tittle, "安装完成")
ControlClick("Button2", tittle, "安装完成")
Exit(0)

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Manipulating TreeView Control in AHKv2

Post by AHK_user » 24 Nov 2022, 01:28

For a more controlled way to manipulate an external treeview, it is better to use my RemoteTreeView class.

viewtopic.php?f=82&t=108274&hilit=treeview

jiaojiaodubai23
Posts: 6
Joined: 22 Nov 2022, 04:16

Re: Manipulating TreeView Control in AHKv2

Post by jiaojiaodubai23 » 03 Dec 2022, 20:55

@AHK_user
Great work! I'll use it to improve my code and make it work more elegantly.

Post Reply

Return to “Ask for Help (v2)”