Jump to content
Sign in to follow this  


Recommended Posts


#include <GuiTreeView.au3>


Local $aListTree[3]
$aListTree[0] = '|' & @TAB
$aListTree[1] = '+----'
$aListTree[2] = '-----'


Func _SaveList()
    Local $AutoItDir, $hFile, $hTreeView, $hWnd, $sControl, $sList, $sPath, $sTitle, $timer, $Wow64
    If @AutoItX64 Then $Wow64 = "\Wow6432Node"
    $AutoItDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir")
    ShellExecute($AutoItDir & '\UDFs3.chm')

    $sTitle = "AutoIt Help" ; En
    If @OSLang = 0419 Then $sTitle = "Справка" ; Ru
    $sControl = "[CLASS:SysTreeView32;INSTANCE:1]"
    $hWnd = WinWait($sTitle, "", 5)
    If Not $hWnd Then Exit MsgBox(4096, 'Err', '$hWnd was not found')

    $hTreeView = ControlGetHandle($hWnd, "", $sControl)
    If Not $hTreeView Then Exit MsgBox(0, 'Err', 'Element was not found')

    $timer = TimerInit()
    _TreeViewToText($sList, $hTreeView)
    If Not $sList Then Exit MsgBox(0, 'Err', 'not $List')
    MsgBox(0, 'Time : ' & Round(TimerDiff($timer) / 1000, 2) & ' sec', $sList)

    $sPath = FileSaveDialog('Save', @ScriptDir, '(*.txt)', 16, 'List+')
    If @error Then Return
    If StringRight($sPath, 4) <> '.txt' Then $sPath &= '.txt'
    $hFile = FileOpen($sPath, 2)
    FileWrite($hFile, $sList)
EndFunc   ;==>_SaveList

; !i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i

Func _TreeViewToText(ByRef $sList, $hTreeView)
    If Not IsHWnd($hTreeView) Then Return SetError(1)

    $hItem = _GUICtrlTreeView_GetFirstItem($hTreeView)
    __TreeViewToText($sList, $hTreeView, $hItem, '')
    $sList = StringTrimRight($sList, 2)
EndFunc   ;==>_TreeViewToText

Func __TreeViewToText(ByRef $sList, $hTreeView, $hItem, $sIndent)
    Local $f, $fFlag, $hItemChild, $sIndentChild
        $fFlag = _GUICtrlTreeView_GetChildren($hTreeView, $hItem) ; Checking the plus sign
        If $fFlag Then
            $f = $aListTree[1]
            $f = $aListTree[2]
        $sList &= $sIndent & $f & _GUICtrlTreeView_GetText($hTreeView, $hItem) & @CRLF

        If $fFlag Then
            $hItemChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem)
            __TreeViewToText($sList, $hTreeView, $hItemChild, $sIndent & $aListTree[0])

        $hItem = _GUICtrlTreeView_GetNextSibling($hTreeView, $hItem)
    Until Not $hItem ; If not handle the output
EndFunc   ;==>__TreeViewToText

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