Jump to content
Sign in to follow this  

How to get tree children as array?

Recommended Posts

I want to store as an array all the monitor names from the "devices" item.


As you can see, all the "devices" children are trees too, don't know if it complicates things.

So the returned array should be this:

['Lenovo LTN116AT06402', 'Lenovo LTN116AT06', 'Lenovo LTN116AT']

This is my current code:

#include <Array.au3>
#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <WinAPIGdi.au3>

; Assign some global variables.

Global $g_sMadPath = 'C:\Program Files\LAV Filters\x86\madVR\'
Global $g_sMadExec = $g_sMadPath & 'madHcCtrl.exe editLocalSettingsDontWait'
Global $g_sMadSett = $g_sMadPath & 'settings.bin'
Global $g_sMadProc = 'madHcCtrl.exe'
Global $g_sMadHand = '[CLASS:TFMadVRSettings]'

; Initialize the madvr settings gui window.

Func Initialize()

    ; Close madvr settings process if exists.
    If ProcessExists($g_sMadProc) Then

    ; Run madvr settings application.

    ; Wait for the madvr settings window.
    WinWaitActive($g_sMadHand, '', 10)

    ; Set window transparency to 0.
    ; WinSetTrans($g_sMadHand, '', 0)


; Get all monitor devices.

Func GetMonitors()

    ; Initialize madvr settings.

    ; Get the tree element handle.
    Local $hTreeView = ControlGetHandle($g_sMadHand, '', 'TTreeView1')
    Local $hDevices = _GUICtrlTreeView_FindItem($hTreeView, 'devices')

    ; Count the devices children, available monitors.
    Local $iChildren = ControlTreeView($g_sMadHand, '', $hTreeView, 'GetItemCount', 'devices')

    ; Array to store children text, the monitor names.
    Local $aMonitorNames = []

    ; TODO: Get children subtree texts and store them inside the array.

    ; Debug: the returned array.

    ; Return the array.
    Return $aMonitorNames



Edited by foozoor

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
Sign in to follow this  

  • Create New...