Jump to content

_TreeViewToText


AZJIO
 Share

Recommended Posts

#include <GuiTreeView.au3>

FileChangeDir(@ScriptDir)

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

_SaveList()

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)
    FileClose($hFile)
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
    Do
        $fFlag = _GUICtrlTreeView_GetChildren($hTreeView, $hItem) ; Checking the plus sign
        If $fFlag Then
            $f = $aListTree[1]
        Else
            $f = $aListTree[2]
        EndIf
        $sList &= $sIndent & $f & _GUICtrlTreeView_GetText($hTreeView, $hItem) & @CRLF

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

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...