NerdySanchez

Selecting child objects in SysTreeView32

4 posts in this topic

Dear AutoIt Forum Users, 

I'm trying to automate a complete installation of the Microsoft LAPS tool using AutoIt.
The problem I am experiencing is selecting and performing actions on objects located inside an instance of class 'SysTreeView32'.

I managed to find example code  on stackoverflow which got me as far as selecting 'Management Tools' (see attached image); however I would like to not only install 'Management Tools', but all child items underneath as well.

I am a novice with AutoIt and would greatly appreciate any assistance. I could not make any sense of how to implement '_GUICtrlTreeView_ClickItem' or '_GUICtrlTreeView_SelectItem' and some examples as to accomplish the task of a complete installation of LAPS is greatly appreciated.

My best,
Nerdy

gotthisfar.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Edited old code. 

Edited by NerdySanchez
Removed old code

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Edited old code

Edited by NerdySanchez
Removed old code

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GuiTreeView.au3>

$title = "Local Administrator Password Solution Setup"
$welcome_title = "Welcome to the Local Administrator Password Solution Setup"
$eula = "End-User License Agreement"
$ready_install = "Ready to install"
$custom_setup = "Custom Setup"
$completed = "Completed"

Run('msiexec /i C:\Staging\LAPS.x64.msi')
Do
    Sleep(500)
Until WinExists($title, $welcome_title)
ControlClick($title, $welcome_title, "[TEXT:&Next]")
Do
    Sleep(500)
Until WinExists($title, $eula)
ControlClick($title, $eula, "[TEXT:I &accept the terms in the License Agreement]")
ControlClick($title, $eula, "[TEXT:&Next]")
Do
    Sleep(500)
Until WinExists($title, $custom_setup)

Local $hWnd = WinGetHandle($title)
$hTreeView = ControlGetHandle($hWnd, "", "[CLASS:SysTreeView32; INSTANCE:1]")
$hTMP = _GUICtrlTreeView_FindItem($hTreeView, "Management Tools", True) 

If $hTMP Then
    _GUICtrlTreeView_Expand($hTreeView,$hTMP, True)
    Sleep(500)
    $hChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hTMP)
    _GUICtrlTreeView_SelectItem($hTreeView, $hChild)
    while $hChild
        _GUICtrlTreeView_SelectItem($hTreeView, $hChild)
        _GUICtrlTreeView_Expand($hTreeView, $hChild, True)
        _GUICtrlTreeView_SelectItem($hTreeView, $hChild)
        ControlSend ("", "", ControlGetFocus ("", ""), "{SPACE}")
        ControlSend ("", "", ControlGetFocus ("", ""), "{DOWN}")
        ControlSend ("", "", ControlGetFocus ("", ""), "{ENTER}")
        $hChild = _GUICtrlTreeView_GetNextChild($hTreeView, $hChild)
        Sleep(500)
    WEnd
Endif

ControlClick($title, $custom_setup, "[TEXT:&Next]")
Do
    Sleep(500)
Until WinExists($title, $ready_install)
ControlClick($title, $ready_install, "[TEXT:&Install]")
Do
    Sleep(2000)
Until WinExists($title, $completed)
ControlClick($title, $completed, "[TEXT:&Finish]")

Edited by NerdySanchez
Updated code

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now