Ordner samt Unterordner in einen TreeView

  • Hallou :D, ich versuche schon seit gestern (wow lange Zeit) ein Programm zu schreiben, welches mir alle unterordner und ordner in einem TreeView anzeigt. Als ListBox habe ich das ganze schon gelöst gehabt, sah aber dann doch etwas "kacke" aus.

    Mein Code sieht immo so aus :

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <GuiListView.au3>
    #include <GuiTreeView.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $Pic1
    $operations = 0
    $TempFolder=""
    $folderinfile=""
    $ViewList=""
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Anime Sammlung", 615, 438, 192, 124)
    ;;$List1 = GUICtrlCreateList("", 8, 8, 153, 409)
    $Open = GUICtrlCreateButton("Ordner öffnen", 528, 392, 75, 25)
    $Label1 = GUICtrlCreateLabel("", 180, 0, 700, 51)
    GUICtrlSetFont(-1, 20, 100, 0, "Segoe Print")
    $TreeView = _GUICtrlTreeView_Create($Form1,8, 8, 175, 409)
    ;$TreeView1 = GUICtrlCreateTreeView(8, 8, 175, 409)
    $naru = _GUICtrlTreeView_Add($TreeView,"","Naruto")
    _GUICtrlTreeView_AddChild($TreeView,$naru,"Shippuuden")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $Listnames = _FileListToArray(@ScriptDir&"Anime")

    [/autoit] [autoit][/autoit] [autoit]

    $desktopini =_ArraySearch($Listnames,"desktop.ini")

    [/autoit] [autoit][/autoit] [autoit]

    For $a=0 to $Listnames[0] step 1
    if $Listnames[$a]="desktop.ini" then
    $operations+=1
    _ArrayDelete($Listnames,$desktopini)
    $Listnames[0] = $Listnames[0]-$operations
    ExitLoop
    EndIf
    next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    For $dir=1 to $Listnames[0] step 1
    $TempFolder=_FileListToArray(@ScriptDir&"Anime"&$Listnames[$dir]&_FileListToArray(@ScriptDir&"Anime"&$Listnames[$dir]))
    For $dirin = 1 to $TempFolder[0] step 1
    if FileGetAttrib(@ScriptDir&"Anime"&$Listnames[$dir]&""&$TempFolder[$dirin]) = "D" Then
    _ArrayAdd($Listnames,$Listnames[$dir]&""&$TempFolder[$dirin])

    [/autoit] [autoit][/autoit] [autoit]

    $Listnames[0]+=1
    EndIf
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    For $ordner=1 to $Listnames[0] step 1
    if FileGetAttrib($TempFolder=_FileListToArray(@ScriptDir&"Anime"&$Listnames[$ordner]))="D" Then
    MsgBox("","",$TempFolder[$ordner])
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    For $i=1 to $Listnames[0] step 1
    if StringInStr("Apple","Apple") Then
    ;MsgBox("","",$Listnames[$i])
    EndIf
    If StringInStr($Listnames[$i],$Listnames[$i]&"") Then MsgBox("","",_GetListName($Listnames,1))
    _GUICtrlTreeView_Add($TreeView,"",$Listnames[$i])
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    while 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Open

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit]

    Ich wollte fragen, wie ich das am besten Löse wenn ich :

    Einen Order habe der bspw. "Naruto" heißt, (im array als Naruto) und 2 unterordner "Naruto" & "Shippuuden"(Im array Naruto\Naruto & Naruto\Shippuuden).

    eine Lösung wäre

    [autoit]

    StringInStr()

    [/autoit]

    aber ich weiß nicht wie genau ich das so einstetzen soll. Und ob das so wie ich das Programmiert habe überhaupt gehen würde.

    [autoit]


    #cs-----------------------------------------------------------------------------
    Hilfe ist immer gut also nimmt sie an ^^
    #ce-----------------------------------------------------------------------------

    [/autoit]

    Einmal editiert, zuletzt von johnnyboyy (6. Dezember 2013 um 11:26)

  • Ich habe keine ahnung wie , aber ich habe irgendwie mein script geschaffen :

    Spoiler anzeigen
    [autoit]


    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Res_SaveSource=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    [/autoit] [autoit][/autoit] [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <GuiListView.au3>
    #include <GuiTreeView.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $Pic1
    $operations = 0
    Global $TempFolder
    $folderinfile=""
    $ViewList=""
    $splitstring = ""

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Anime Sammlung", 615, 438, 192, 124)
    ;;$List1 = GUICtrlCreateList("", 8, 8, 153, 409)
    $Open = GUICtrlCreateButton("Ordner öffnen", 528, 392, 75, 25)
    $Label1 = GUICtrlCreateLabel("", 180, 0, 700, 51)
    GUICtrlSetFont(-1, 20, 100, 0, "Segoe Print")
    $TreeView = _GUICtrlTreeView_Create($Form1,8, 8, 175, 409)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $Listnames = _FileListToArray(@ScriptDir&"Anime")
    ;~ Global $ListSubFolders
    global $this
    global $ListSubFolders[1]
    $desktopini =_ArraySearch($Listnames,"desktop.ini")

    [/autoit] [autoit][/autoit] [autoit]

    For $a=0 to $Listnames[0] step 1
    if $Listnames[$a]="desktop.ini" then
    $operations+=1
    _ArrayDelete($Listnames,$desktopini)
    $Listnames[0] = $Listnames[0]-$operations
    ExitLoop
    EndIf
    next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    For $dir=1 to $Listnames[0] step 1
    $TempFolder=_FileListToArray(@ScriptDir&"Anime"&$Listnames[$dir]&_FileListToArray(@ScriptDir&"Anime"&$Listnames[$dir]))
    $hHandle = _GUICtrlTreeView_Add($TreeView,"",$Listnames[$dir])
    For $dirin = 1 to $TempFolder[0] step 1
    if FileGetAttrib(@ScriptDir&"Anime"&$Listnames[$dir]&""&$TempFolder[$dirin]) = "D" Then
    _ArrayAdd($ListSubFolders,$Listnames[$dir]&""&$TempFolder[$dirin])

    [/autoit] [autoit][/autoit] [autoit]

    ;~ _GUICtrlTreeView_Add($TreeView,"",$Listnames[$dir]&""&$TempFolder[$dirin])
    _GUICtrlTreeView_AddChild($TreeView,$hHandle,$TempFolder[$dirin])
    $ListSubFolders[0]+=1

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Next
    ;~ _ArrayDisplay($ListSubFolders)
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    while 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Open

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit]

    Sieht so wie es ist, sehr gut aus. Wie gesagt, ich habe keine Ahnung was genau ich da gemacht habe, hab dauernd Code versucht zu ändern, dann gings auf einmal. :D

    [autoit]


    #cs-----------------------------------------------------------------------------
    Hilfe ist immer gut also nimmt sie an ^^
    #ce-----------------------------------------------------------------------------

    [/autoit]

    Einmal editiert, zuletzt von johnnyboyy (3. Dezember 2013 um 17:22)