Hilfe bei Editor mit ComboBox und Tree-Struktur

  • Hallo alle zusammen!!!,

    Ich habe folgendes Problem: Ich möchte so wie im Bild zwei ComboBoxen (jeweils mit Laufwerkinhalt) und einer Tree-Struktur des ausgewählen Laufwerks anzeigen lassen. Der gewählte Inhalt sollte denn in der MItte angezeigt werden.


    autoit.de/wcf/attachment/7396/


    Wer kann mir dabei helfen und Tipps geben?


    Spoiler anzeigen
    [autoit]


    #Include <Array.au3>
    #include <Constants.au3>
    #Include <File.au3>
    #include <GDIPlus.au3>
    #include <GUIComboBox.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #include <Process.au3>
    #include <StaticConstants.au3>
    #include <TreeViewConstants.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Opt("WinTitleMatchMode", 4)

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

    Local $filemenu, $fileitem, $recentfilesmenu, $separator1, $var, $add, $treetoview1, $GetIcon
    Local $exititem, $helpmenu, $aboutitem, $Apsbutton, $Unapsbutton, $Checkbox, $Runbox
    Local $msg, $file, $file2, $fileitem2, $View2, $View3, $Deletebutton, $to1, $to2, $toPath, $item1, $ViewItem1, $a2
    Local $Drivers1, $Drivers2, $Readdriver1, $Readdriver2, $driver

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

    Global $hGUI, $hImage, $hGraphic, $i, $iF, $aFiles, $aDirectorys, $aDirNames, $aFileNames, $i2, $iF2, $aFiles2, $aDirectorys2, $aDirNames2, $aFileNames2
    Global $i3, $iF3, $aFiles3, $aDirectorys3, $aDirNames3, $aFileNames3, $hList32

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

    ; Global left box
    Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "D:\", $sStartDir2= "C:\"

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

    #forceref $separator1

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

    ; file
    $hGUI = GUICreate("Aps / Unaps - by MacroMan", 575, 260, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010)

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

    ; Buttons
    $Apsbutton = GUICtrlCreateButton("Aps", 333, 16, 70, 20)
    $Unapsbutton = GUICtrlCreateButton("Unaps", 333, 56, 70, 20)
    $Deletebutton = GUICtrlCreateButton("Delete", 333, 96, 70, 20)
    $Checkbox = GUICtrlCreateCheckbox("To hide", 333, 156, 70, 20)
    $exititem = GUICtrlCreateButton("Exit", 333, 226, 70, 20)
    $to1 = _GUICtrlComboBox_Create($hGUI, "", 5 ,5 ,165, 20)
    $to2 = _GUICtrlComboBox_Create($hGUI, "", 410 ,5 ,165, 20)
    GUISetState(@SW_SHOW)

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

    ; Drivers left combo box
    _GUICtrlComboBox_BeginUpdate($to1)
    _GUICtrlComboBox_AddDir($to1, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to1)

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

    ; Drivers right combo box
    _GUICtrlComboBox_BeginUpdate($to2)
    _GUICtrlComboBox_AddDir($to2, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to2)

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

    ; Read from drivers left combo box
    $Readdriver1 = GUICtrlRead($to1, 0)

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

    ; Read from drivers left combo box
    $Readdriver2 = GUICtrlRead($to2, 0)

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

    ; Create left box
    Run('explorer.exe /n, "' & $sStartDir & '"')
    WinWait("[CLASS:CabinetWClass]")

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

    $hExplorer = WinGetHandle("[CLASS:CabinetWClass]")
    $hList32 = ControlGetHandle ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]")

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

    _WinAPI_SetParent($hList32, $hGUI)

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

    ControlListView ($hExplorer, "", $hList32, "ViewChange", "list")
    WinSetState($hExplorer, "", @SW_HIDE)
    WinMove($hList32, "", 5, 25, 165, 235)

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

    ; Create right box
    Run('explorer.exe /n, "' & $sStartDir2 & '"')
    WinWait("[CLASS:CabinetWClass]")

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

    $hExplorer = WinGetHandle("[CLASS:CabinetWClass]")
    $hList32 = ControlGetHandle ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]")

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

    _WinAPI_SetParent($hList32, $hGUI)

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

    ControlListView ($hExplorer, "", $hList32, "ViewChange", "list")
    WinSetState($hExplorer, "", @SW_HIDE)
    WinMove($hList32, "", 410, 25, 165, 235)

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

    ; Create middle box
    $hList = GUICtrlCreateListView ("", 170, 5, 155, 256)
    GUICtrlSetState (-1, 8)

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

    WinSetState($hExplorer, "", @SW_SHOW)
    GUISetState(@SW_SHOW, $hGUI)

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

    $aDirectorys3 = _FileListToArray($hList, '*.*', 1)
    _ArrayDelete($aDirectorys3, 0)

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

    ; Read data in middle box

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

    ; Function Menu
    While 1
    $msg = GUIGetMsg()
    Switch $Msg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $exititem
    Exit
    Case $Apsbutton
    _RunAps()
    Case $UnApsbutton
    _RunUnaps()
    Case -3
    Exit
    Case -13
    GUICtrlCreateListViewItem (@GUI_DRAGFILE, $hList)
    EndSwitch
    WEnd

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

    ;Function Run to "_aps.exe"
    Func _RunAps()
    Run("_aps.exe " & $aDirectorys3)
    EndFunc ;==> RunAps

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

    ; Function Run to "_unaps.exe"
    Func _RunUnaps()
    Run("_unaps.exe " & $aDirectorys3)
    EndFunc ;==> RunUnaps

    [/autoit]

    LG

  • Hab' mein Skript nochmal überarbeitet. Die Tree-Struktur funktioniert zwar etwas langsam aber sie funktionert ! Ich habe aber noch folgende Probleme:

    - Tree-Struktur soll den Inhalt des ausgewählten Laufwerkes anzeigen und nicht den gesamten Arbeitsplatz.
    - Die exe "Aps" und "UnAps" können keinen Bezug zum ausgewählten Inhalt von der Tree-Struktur herstellen.
    - Tree-Struktur soll nur Ordner anzeigen, die Dateien sollen in der ListView in der Mitte angezeigt werden.
    - Vielleicht gibt es auch eine Möglichkeit dass das Skript schneller läuft

    Spoiler anzeigen
    [autoit]


    #include <Constants.au3>
    #include <GUIComboBox.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiTreeView.au3>
    #include <StructureConstants.au3>
    #include <TreeViewConstants.au3>
    #include <WindowsConstants.au3>

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

    ; file and buttons
    $hGUI = GUICreate("Aps / Unaps - by MacroMan", 575, 260)
    $hTreeview1 = GUICtrlCreateTreeView(5, 25, 165, 230)
    $hWndTreeview1 = GUICtrlGetHandle($hTreeview1)
    $hTreeview2 = GUICtrlCreateTreeView(410, 25, 165, 230)
    $hWndTreeview2 = GUICtrlGetHandle($hTreeview2)
    $Listview = GUICtrlCreateListView(" ",175, 5, 155, 252)
    $Apsbutton = GUICtrlCreateButton("Aps", 333, 16, 70, 20)
    $Unapsbutton = GUICtrlCreateButton("Unaps", 333, 56, 70, 20)
    $Deletebutton = GUICtrlCreateButton("Delete", 333, 96, 70, 20)
    $Checkbox = GUICtrlCreateCheckbox("To hide", 333, 156, 70, 20)
    $exititem = GUICtrlCreateButton("Exit", 333, 226, 70, 20)
    $to1 = _GUICtrlComboBox_Create($hGUI, "", 5 ,5 ,165, 20)
    $to2 = _GUICtrlComboBox_Create($hGUI, "", 410 ,5 ,165, 20)

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

    ; Drivers left combo box
    _GUICtrlComboBox_BeginUpdate($to1)
    $iDriver = _GUICtrlComboBox_AddDir($to1, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to1)

    ; Drivers right combo box
    _GUICtrlComboBox_BeginUpdate($to2)
    $iDriver2 = _GUICtrlComboBox_AddDir($to2, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to2)

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

    ; left TreeView
    $hImage = _GUIImageList_Create(16, 16, 5, 1)
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 3) ; FolderIcon
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 110) ; FolderIcon mit Haken
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 1) ; DataIcon
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 5) ; Disk
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 7) ; Wechseldatenträger
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 8) ; Festplatte
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 11) ; DiskDriver
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 12) ; Netzwerklaufwerk
    _GUIImageList_AddIcon($hImage, 'shell32.dll', 53) ; Unknow
    _GUICtrlTreeView_SetNormalImageList($hTreeview1, $hImage)

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

    GUISetState()
    GUICtrlSetStyle($hTreeview1, Default, $WS_EX_COMPOSITED + $WS_EX_CLIENTEDGE)

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

    $aDrives = DriveGetDrive('ALL')
    ToolTip('Please wait...', Default, Default, 'Read Directory', 1)
    For $i = 1 To $aDrives[0]
    $iLWindex = 0
    Switch DriveGetType($aDrives[$i])
    Case 'Fixed'
    $iLWindex = 5
    Case 'CDROM'
    $iLWindex = 6
    Case 'RAMDisk'
    $iLWindex = 7
    Case 'Removable'
    $iLWindex = 4
    If StringLeft($aDrives[$i], 2) = 'a:' Or StringLeft($aDrives[$i], 2) = 'b:' Then $iLWindex = 3
    Case Else
    $iLWindex = 8
    EndSwitch
    $hRoot = _GUICtrlTreeView_Add($hTreeview1, $hTreeview1, StringUpper($aDrives[$i]), $iLWindex, $iLWindex)
    If DriveStatus($aDrives[$i]) <> 'READY' Then ContinueLoop
    _GUICtrlTreeView_BeginUpdate($hTreeview1)
    _GUICtrlTreeView_FileExplorerRecursive($hTreeview1, $hRoot, $aDrives[$i], 1)
    _GUICtrlTreeView_EndUpdate($hTreeview1)
    Next
    ToolTip('')

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

    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $exititem
    Exit
    Case -13
    GUICtrlCreateListViewItem ("", $Listview)
    Case $deletebutton
    $iSelect = _GUICtrlTreeView_GetSelection($hTreeview1)
    $sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview1, $iSelect), '|', '\')
    MsgBox(0, 'Selected Path/File', $sTree)
    EndSwitch
    WEnd

    Func _RunAps()
    Run("_aps.exe " & $aDirectorys3)
    EndFunc

    Func _RunUnaps()
    Run("_unaps.exe " & $aDirectorys3)
    EndFunc

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

    ; left TreeView
    Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    GUIRegisterMsg($WM_NOTIFY, '')
    Local $hWndFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
    $iCode = DllStructGetData($tNMHDR, 'Code')
    If $hWndFrom = $hWndTreeview1 And $iCode = $NM_CLICK Then
    ToolTip('Please wait...', Default, Default, 'Read wectory', 1)
    _GUICtrlTreeView_FileExplorer($hGui, $hTreeview1)
    ToolTip('')
    EndIf
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_NOTIFY

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

    Func _GUICtrlTreeView_FileExplorer($hGui, $hTreeview1)
    Local $aTVPos, $aPos, $hItem, $hChild, $sTree
    $aTVPos = ControlGetPos($hGui, '', $hTreeview1)
    $aPos = GUIGetCursorInfo($hGui)
    $hItem = _GUICtrlTreeView_HitTestItem($hTreeview1, $aPos[0], $aPos[1] - $aTVPos[1])
    If _GUICtrlTreeView_GetExpanded($hTreeview1, $hItem) Then Return
    $hChild = _GUICtrlTreeView_GetFirstChild($hTreeview1, $hItem)
    If $hChild <> 0 Then
    _GUICtrlTreeView_BeginUpdate($hTreeview1)
    $sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview1, $hChild), '|', '\')
    _GUICtrlTreeView_DeleteChildren($hTreeview1, $hChild)
    _GUICtrlTreeView_FileExplorerRecursive($hTreeview1, $hChild, $sTree, 1)
    Do
    $hChild = _GUICtrlTreeView_GetNextChild($hTreeview1, $hChild)
    If $hChild <> 0 Then
    $sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview1, $hChild), '|', '\')
    _GUICtrlTreeView_DeleteChildren($hTreeview1, $hChild)
    $iTimer = TimerInit()
    _GUICtrlTreeView_FileExplorerRecursive($hTreeview1, $hChild, $sTree, 1)
    EndIf
    Until $hChild = 0
    _GUICtrlTreeView_EndUpdate($hTreeview1)
    EndIf
    EndFunc ;==>_GUICtrlTreeView_FileExplorer

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

    Func _GUICtrlTreeView_FileExplorerRecursive($hTreeview1, $hItem, $sPath, $iRec)
    Local $aDirList, $aFileList, $tmp
    If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
    $iRec -= 1
    $aDirList = _MyFileListToArray($sPath, 2)
    If IsArray($aDirList) Then
    For $sDir In $aDirList
    $tmp = _GUICtrlTreeView_AddChild($hTreeview1, $hItem, $sDir, 0, 1)
    If $iRec > 0 Then _GUICtrlTreeView_FileExplorerRecursive($hTreeview1, $tmp, $sPath & $sDir, $iRec)
    Next
    EndIf
    $aFileList = _MyFileListToArray($sPath, 1)
    If IsArray($aFileList) Then
    For $sFile In $aFileList
    $tmp = _GUICtrlTreeView_AddChild($hTreeview1, $hItem, $sFile, 2, 2)
    Next
    EndIf
    EndFunc ;==>_GUICtrlTreeView_FileExplorerRecursive

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

    Func _MyFileListToArray($sPath, $iFlag)
    Local $sFileList = '', $hSearch, $sFile
    $hSearch = FileFindFirstFile($sPath & '*')
    If @error Then Return
    While True
    $sFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    If ($iFlag + @extended = 2) Then ContinueLoop
    $sFileList &= $sFile & '|'
    WEnd
    FileClose($hSearch)
    If $sFileList = '' Then Return
    Return StringSplit(StringTrimRight($sFileList, 1), '|', 2)
    EndFunc ;==>__FileListToArray

    [/autoit]

    2 Mal editiert, zuletzt von MacroMan (28. Januar 2010 um 16:14)

  • Hmmm.... klappt nicht so ganz:

    P.S.: Nimm bitte den AutoIt Quellcode, dann übersetzt der auch keine Smilies und das Script ist dann auch schön bunt :D

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"

  • So, hab' alles nochmal schnell Überarbeitet. Nun ist auch alles schön bund und im Spoiler. :rofl:

  • So hab' nun das Geschwindigkeitsproblem gelöst. Läuft jetzt perfekt!!! Nun soll noch die ListView den Inhalt aus den gewählten Ordner anzeigen. Außerdem möchte ich noch die Laufwerke mit der ComboBox auswählen und es soll der gewählte Inhalt mit der ausgewählten .exe Datei ausgeführt werden. Wer kann denn da helfen??? Wozu ich das eigentlich brauche??? Das soll ein Tool für den Sudden Strike Applikator Hidden Stroke 2 werden mit dem man die Dateien .aps entpacken kann.

    Spoiler anzeigen
    [autoit]


    #Region Header
    #include-once
    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <WindowsConstants.au3>
    #include <array.au3>

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

    GUIRegisterMsg($WM_NOTIFY, "EXPLORER_WM_NOTIFY")
    OnAutoItExitRegister('__EXIT')

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

    #EndRegion Header

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

    #Region Global Variables and Constants

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

    Global $Shell32 = DllOpen('shell32.dll')
    Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1)
    Global $aListViews[1][7] = [[0, 'Current Dir', 'Dir History', 'Columns', 'Function', 'ColumnWidths', 'ShowHidden']]

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

    #EndRegion Global Variables and Constants
    #Region Public Functions
    Func _ExpListView_Create($hWnd, $sStartDir, $iColumns, $bShowHidden = False, $iX = 1, $iY = 1, $iWidth = 1800, $iHeight = 10, $iStyle = 0x0000000D, $iExStyle = 0x00000000, $fCoInit = False)
    Local $hListView = _GUICtrlListView_Create($hWnd, 'Name', $iX, $iY, $iWidth, $iHeight, $iStyle, $iExStyle, $fCoInit)
    If $hListView = 0 Then Return SetError(1, @extended, 0)
    _GUICtrlListView_SetImageList($hListView, _GUIImageList_GetSystemImageList(), 1)
    ReDim $aListViews[UBound($aListViews) + 1][UBound($aListViews, 2)]
    $aListViews[0][0] += 1
    $aListViews[$aListViews[0][0]][0] = $hListView
    $aListViews[$aListViews[0][0]][1] = $sStartDir
    $aListViews[$aListViews[0][0]][5] = '50;50;50;50;50'
    $aListViews[$aListViews[0][0]][6] = $bShowHidden
    _ExpListView_SetColumns($hListView, $iColumns, False)
    _ChangeDir($aListViews[0][0], $sStartDir, False)
    Return $hListView
    EndFunc ;==>_ExpListView_Create

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

    Func _ExpListView_Create2($hWnd, $sStartDir, $iColumns, $bShowHidden = False, $iX = 1, $iY = 1, $iWidth = 1800, $iHeight = 10, $iStyle = 0x0000000D, $iExStyle = 0x00000000, $fCoInit = False)
    Local $hListView = _GUICtrlListView_Create($hWnd, 'ListView', $iX, $iY, $iWidth, $iHeight, $iStyle, $iExStyle, $fCoInit)
    If $hList1 = 0 Then Return SetError(1, @extended, 0)
    _GUICtrlListView_SetImageList($hList1, _GUIImageList_GetSystemImageList(), 1)
    ReDim $aListViews[UBound($aListViews) + 1][UBound($aListViews, 2)]
    $aListViews[0][0] += 1
    $aListViews[$aListViews[0][0]][0] = $hListView
    $aListViews[$aListViews[0][0]][1] = $sStartDir
    $aListViews[$aListViews[0][0]][5] = '50;50;50;50;50'
    $aListViews[$aListViews[0][0]][6] = $bShowHidden
    _ExpListView_SetColumns($hListView, $iColumns, False)
    _ChangeDir2($aListViews[0][0], $sStartDir, False)
    Return $hListView
    EndFunc ;==>_ExpListView_Create

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

    Func _ExpListView_Back($hWnd)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    Local $sPop = _HistoryPoP($iArrayIndex)
    If $sPop = -1 Then Return 2;History Stack is empty
    _ChangeDir($iArrayIndex, $sPop, False)
    Return 1
    EndFunc ;==>_ExpListView_Back

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

    Func _ExpListView_DirGetCurrent($hWnd)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    Return $aListViews[$iArrayIndex][1]
    EndFunc ;==>_ExpListView_DirGetCurrent

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

    Func _ExpListView_DirSetCurrent($hWnd, $sDirectory)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    If Not FileExists($sDirectory) Then Return SetError(2, @extended, 0) ;invalad Directory
    _ChangeDir($iArrayIndex, $sDirectory)
    Return 1
    EndFunc ;==>_ExpListView_DirSetCurrent

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

    Func _ExpListView_SetColumns($hWnd, $iColunms, $bRefresh = True)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd

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

    _SaveColunmWidths($iArrayIndex, $hWnd)
    $aListViews[$iArrayIndex][3] = $iColunms

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

    _SetColumnsWidths($iArrayIndex, $hWnd)

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

    If $bRefresh Then _ChangeDir($iArrayIndex, $aListViews[$iArrayIndex][1], False)
    Return 1
    EndFunc ;==>_ExpListView_SetColumns

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

    Func _ExpListView_SetFunction($hWnd, $sFunction)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    $aListViews[$iArrayIndex][4] = $sFunction
    Return 1
    EndFunc ;==>_ExpListView_SetFunction

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

    Func _ExpListView_ShowHiddenFiles($hWnd, $bShowHidden)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    If $bShowHidden Or Not $bShowHidden Then
    $aListViews[$iArrayIndex][6] = $bShowHidden
    Return 1
    EndIf
    Return SetError(2, @extended, 0);invalad Flag
    EndFunc ;==>_ExpListView_ShowHiddenFiles

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

    Func _ExpListView_Refresh($hWnd)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    _ChangeDir($iArrayIndex, $aListViews[$iArrayIndex][1], False)
    EndFunc ;==>_ExpListView_Refresh

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

    Func _ExpListView_ColumnViewsSave($hWnd)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    _SaveColunmWidths($iArrayIndex, $hWnd)
    Return ($aListViews[$iArrayIndex][3] & '|' & _GUICtrlListView_GetColumnWidth($hWnd, 0) & '|' & $aListViews[$iArrayIndex][5])
    EndFunc ;==>_ExpListView_ColumnViewsSave

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

    Func _ExpListView_ColumnViewsRestore($hWnd, $sColumnViews)
    Local $iArrayIndex = _GetIndex($hWnd)
    If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd
    Local $aSplit = StringSplit($sColumnViews, '|')
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $aSplit[2])
    $aListViews[$iArrayIndex][5] = $aSplit[3]
    _SetColumnsWidths($iArrayIndex, $hWnd)
    _ExpListView_SetColumns($hWnd, $aSplit[1])
    EndFunc ;==>_ExpListView_ColumnViewsRestore
    #EndRegion Public Functions

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

    #Region Internal Functions
    Func EXPLORER_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    If $iCode = $NM_DBLCLK Then ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $hWndFrom, $tInfo, $iArrayIndex
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    $iArrayIndex = _GetIndex($hWndFrom)
    _GetChangeDir($iArrayIndex, DllStructGetData($tInfo, "Index"))
    If $aListViews[$iArrayIndex][4] <> '' Then Call($aListViews[$iArrayIndex][4], $hWndFrom)
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc ;==>EXPLORER_WM_NOTIFY
    Func _SetColumnsWidths($iArrayIndex, $hWnd)
    Local $iColumnCount = _GUICtrlListView_GetColumnCount($hWnd)
    For $i = 1 To $iColumnCount
    _GUICtrlListView_DeleteColumn($hWnd, 1)
    Next

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

    Local $aColumnWidths = StringSplit($aListViews[$iArrayIndex][5], ';')
    If BitAND($aListViews[$iArrayIndex][3], 2) Then _GUICtrlListView_AddColumn($hWnd, 'Modified', Int($aColumnWidths[2]))
    EndFunc ;==>_SetColumnsWidths
    Func _SaveColunmWidths($iArrayIndex, $hWnd)
    Local $i, $aColumnWidths, $iColunmValue = 1, $iColunmIndex = 1
    $aColumnWidths = StringSplit($aListViews[$iArrayIndex][5], ';')

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

    For $i = 1 To 5
    If BitAND($aListViews[$iArrayIndex][3], $iColunmValue) Then
    $aColumnWidths[$i] = _GUICtrlListView_GetColumnWidth($hWnd, $iColunmIndex)
    $iColunmIndex += 1
    EndIf
    $iColunmValue += $iColunmValue
    Next

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

    $aListViews[$iArrayIndex][5] = _ArrayToString($aColumnWidths, ';', 1)
    EndFunc ;==>_SaveColunmWidths
    Func _GetIndex($hWnd)
    Local $i
    For $i = 1 To $aListViews[0][0]
    If $aListViews[$i][0] = $hWnd Then Return $i
    Next
    Return -1
    EndFunc ;==>_GetIndex
    Func _ParentDirectory($iArrayIndex)
    Local $aDirSplit, $sChangeDir
    $aDirSplit = StringSplit($aListViews[$iArrayIndex][1], '\')
    If $aDirSplit[0] = 2 Then
    If $aDirSplit[2] = '' Then
    $sChangeDir = 'My Computer'
    Else
    $sChangeDir = $aDirSplit[1] & '\'
    EndIf
    Else
    For $i = 1 To $aDirSplit[0] - 1
    $sChangeDir &= $aDirSplit[$i] & '\'
    Next
    $sChangeDir = StringTrimRight($sChangeDir, 1)
    EndIf
    _ChangeDir($iArrayIndex, $sChangeDir)
    EndFunc ;==>_ParentDirectory
    Func _GetChangeDir($iArrayIndex, $iListIndex)
    Local $sChangeDir, $sItemText = _GUICtrlListView_GetItemText($aListViews[$iArrayIndex][0], $iListIndex)
    Select
    Case $sItemText = '[..]'
    _ParentDirectory($iArrayIndex)
    Return
    Case $aListViews[$iArrayIndex][1] = 'My Computer'
    $sChangeDir = StringMid($sItemText, StringInStr($sItemText, '(') + 1, 2) & '\'
    Case Else
    If StringRight($aListViews[$iArrayIndex][1], 1) = '\' Then
    $sChangeDir = $aListViews[$iArrayIndex][1] & $sItemText
    Else
    $sChangeDir = $aListViews[$iArrayIndex][1] & '\' & $sItemText
    EndIf
    If StringInStr(FileGetAttrib($sChangeDir), 'D') = 0 Then Return
    EndSelect
    _ChangeDir($iArrayIndex, $sChangeDir)
    EndFunc ;==>_GetChangeDir
    Func _ChangeDir($iArrayIndex, $sDirectory, $bPushHistory = True)
    If $sDirectory = 'My Computer' Then
    If $bPushHistory Then _HistoryPush($iArrayIndex, $aListViews[$iArrayIndex][1])
    _MyComputer($iArrayIndex)
    Return
    EndIf
    Local $aList, $sFile, $sAttributes, $iIcon, $iItem, $iSize, $aTime, $iColumnIndex = 1
    _GUICtrlListView_DeleteAllItems($aListViews[$iArrayIndex][0])
    $aList = _FileListToArray_mod($sDirectory)
    _GUICtrlListView_BeginUpdate($aListViews[$iArrayIndex][0])
    _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], "[..]", $FOLDER_ICON_INDEX)

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

    If IsArray($aList) Then
    For $i = 1 To $aList[0]
    $sFile = $sDirectory & '\' & $aList[$i]
    $sAttributes = FileGetAttrib($sFile)
    If Not $aListViews[$iArrayIndex][6] Then;ShowHidden
    If StringInStr($sAttributes, 'H') > 0 Then ContinueLoop
    EndIf
    If StringInStr($sAttributes, 'D') > 0 Then
    $iIcon = $FOLDER_ICON_INDEX
    Else
    $iIcon = _GUIImageList_GetFileIconIndex($aList[$i])
    EndIf
    $iItem = _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], $aList[$i], $iIcon)
    ;
    If BitAND($aListViews[$iArrayIndex][3], 1) Then ;size
    If $iIcon = $FOLDER_ICON_INDEX Then
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, 'DIR', $iColumnIndex)
    Else
    $iSize = FileGetSize($sFile)
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, _bytes($iSize), $iColumnIndex)
    EndIf
    $iColumnIndex += 1
    EndIf
    If BitAND($aListViews[$iArrayIndex][3], 2) Then ;Modified
    $aTime = FileGetTime($sFile, 0)
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex)
    $iColumnIndex += 1
    EndIf
    If BitAND($aListViews[$iArrayIndex][3], 4) Then ;Attributes
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $sAttributes, $iColumnIndex)
    $iColumnIndex += 1
    EndIf

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

    If BitAND($aListViews[$iArrayIndex][3], 8) Then;Creation
    $aTime = FileGetTime($sFile, 1)
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex)
    $iColumnIndex += 1
    EndIf
    If BitAND($aListViews[$iArrayIndex][3], 16) Then;Accessed
    $aTime = FileGetTime($sFile, 2)
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex)
    $iColumnIndex += 1
    EndIf
    $iColumnIndex = 1
    Next
    EndIf
    _GUICtrlListView_EndUpdate($aListViews[$iArrayIndex][0])
    If $bPushHistory Then _HistoryPush($iArrayIndex, $aListViews[$iArrayIndex][1])
    $aListViews[$iArrayIndex][1] = $sDirectory
    EndFunc ;==>_ChangeDir
    Func _ChangeDir2($iArrayIndex, $sDirectory, $bPushHistory = True)
    Local $aList, $sFile, $sAttributes, $iIcon, $iItem, $iSize, $aTime, $iColumnIndex = 1
    _GUICtrlListView_DeleteAllItems($aListViews[$iArrayIndex][0])
    $aList = _FileListToArray_mod($sDirectory)
    _GUICtrlListView_BeginUpdate($aListViews[$iArrayIndex][0])
    _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], "[..]", $FOLDER_ICON_INDEX)

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

    If IsArray($aList) Then
    For $i = 1 To $aList[0]
    $sFile = $sDirectory & '\' & $aList[$i]
    $sAttributes = FileGetAttrib($sFile)
    If Not $aListViews[$iArrayIndex][6] Then;ShowHidden
    If StringInStr($sAttributes, 'H') > 0 Then ContinueLoop
    EndIf
    If StringInStr($sAttributes, 'D') > 0 Then
    $iIcon = $FOLDER_ICON_INDEX
    Else
    $iIcon = _GUIImageList_GetFileIconIndex($aList[$i])
    EndIf
    Next
    EndIf
    _GUICtrlListView_EndUpdate($aListViews[$iArrayIndex][0])
    If $bPushHistory Then _HistoryPush($iArrayIndex, $aListViews[$iArrayIndex][1])
    $aListViews[$iArrayIndex][1] = $sDirectory
    EndFunc ;==>_ChangeDir
    Func _MyComputer($iArrayIndex)
    Local $drives, $attributes, $item, $Time, $iColunmIndex = 1
    $aListViews[$iArrayIndex][1] = 'My Computer'
    _GUICtrlListView_DeleteAllItems($aListViews[$iArrayIndex][0])
    $drives = DriveGetDrive("ALL")
    For $i = 1 To $drives[0]
    $item = _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], DriveGetLabel($drives[$i] & '\') & ' (' & StringUpper($drives[$i]) & ')', _GUIImageList_GetFileIconIndex($drives[$i] & '\'))
    If BitAND($aListViews[$iArrayIndex][3], 1) Then ;size
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $item, 'DIR', $iColunmIndex)
    $iColunmIndex += 1
    EndIf
    If BitAND($aListViews[$iArrayIndex][3], 2) Then $iColunmIndex += 1;Modified
    If BitAND($aListViews[$iArrayIndex][3], 4) Then;Attributes
    $attributes = FileGetAttrib($drives[$i] & '\')
    _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $item, $attributes, $iColunmIndex)
    EndIf
    $iColunmIndex = 1
    Next
    EndFunc ;==>_MyComputer
    Func _HistoryPush($iArrayIndex, $sDir)
    $aListViews[$iArrayIndex][2] = $sDir & '|' & $aListViews[$iArrayIndex][2]
    EndFunc ;==>_HistoryPush
    Func _HistoryPoP($iArrayIndex)
    Local $aSplit = StringSplit($aListViews[$iArrayIndex][2], '|', 2)
    If $aSplit[0] = '' Then Return -1
    Local $sReturn = $aSplit[0]
    _ArrayDelete($aSplit, 0)
    $aListViews[$iArrayIndex][2] = _ArrayToString($aSplit, '|')
    Return $sReturn
    EndFunc ;==>_HistoryPoP
    Func _FileListToArray_mod($sPath, $sFilter = "*", $iFlag = 0)
    Local $hSearch, $sFile, $sFileList, $sFolderList, $sDelim = "|"
    $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    $hSearch = FileFindFirstFile($sPath & $sFilter)
    If @error Then Return SetError(4, 4, "")
    While 1
    $sFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    If @extended Then
    $sFolderList &= $sDelim & $sFile
    Else
    $sFileList &= $sDelim & $sFile
    EndIf
    WEnd
    FileClose($hSearch)
    $sFileList = $sFolderList & $sFileList
    If Not $sFileList Then Return SetError(4, 4, "")
    Return StringSplit(StringTrimLeft($sFileList, 1), "|")
    EndFunc ;==>_FileListToArray_mod
    Func _bytes($iBytes)
    Switch $iBytes
    Case 0 To 1023
    Return $iBytes & " Bytes"
    Case 1024 To 1048575
    Return Round($iBytes / 1024, 2) & " KB"
    Case 1048576 To 1073741823
    Return Round($iBytes / 1048576, 2) & " MB"
    Case Else
    Return Round($iBytes / 1073741824, 2) & " GB"
    EndSwitch
    EndFunc ;==>_bytes
    Func __EXIT()
    DllClose($Shell32)
    EndFunc ;==>__EXIT
    ;Originally written by Prog@ndy
    Func _GUIImageList_GetSystemImageList($bLargeIcons = False)
    Local $SHGFI_USEFILEATTRIBUTES = 0x10, $SHGFI_SYSICONINDEX = 0x4000, $SHGFI_SMALLICON = 0x1;, $SHGFI_LARGEICON = 0x0;,$FILE_ATTRIBUTE_NORMAL = 0x80
    Local $FileInfo = DllStructCreate("dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];")
    Local $dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX)
    If Not ($bLargeIcons) Then $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
    Local $hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags)
    Return $hIml
    EndFunc ;==>_GUIImageList_GetSystemImageList
    Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False);modified
    Static $FileInfo = DllStructCreate("dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];")
    Local $dwFlags = BitOR(0x4000, 0x1)
    If Not $bForceLoadFromDisk Then $dwFlags = BitOR($dwFlags, 0x10)
    DllCall($Shell32, "DWORD*", "SHGetFileInfo", "str", $sFileSpec, "DWORD", $FILE_ATTRIBUTE_NORMAL, "ptr", DllStructGetPtr($FileInfo), "UINT", DllStructGetSize($FileInfo), "UINT", $dwFlags)
    If @error Then Return SetError(1, 0, -1)
    Return DllStructGetData($FileInfo, "iIcon")
    EndFunc ;==>_GUIImageList_GetFileIconIndex
    Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags)
    Local $return = DllCall($Shell32, "DWORD*", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags)
    If @error Then Return SetError(@error, 0, 0)
    Return $return[0]
    EndFunc ;==>_WinAPI_SHGetFileInfo
    #EndRegion Internal Functions

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

    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>
    #include <GUIComboBox.au3>

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

    OnAutoItExitRegister('_Exit')

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

    $hGUI = GUICreate("Aps / Unaps - by MacroMan Arts", 575, 260)
    Global $hList1 = _ExpListView_Create($hGUI, 'c:\', 1, False, 5, 27, 165, 230)
    Global $hList2 = _ExpListView_Create($hGUI, 'My Computer', 1, False, 410, 27, 165, 230)
    Global $Listview = _ExpListView_Create2($hGUI, $hList2, 1, False, 175, 5, 155, 252)
    Global $Apsbutton = GUICtrlCreateButton("Aps", 333, 16, 70, 20)
    Global $Unapsbutton = GUICtrlCreateButton("Unaps", 333, 56, 70, 20)
    Global $Deletebutton = GUICtrlCreateButton("Delete", 333, 96, 70, 20)
    Global $Checkbox = GUICtrlCreateCheckbox("To hide", 333, 156, 70, 20)
    Global $exititem = GUICtrlCreateButton("Exit", 333, 226, 70, 20)
    Global $to1 = _GUICtrlComboBox_Create($hGUI, "", 5 ,5 ,165, 20)
    Global $to2 = _GUICtrlComboBox_Create($hGUI, "", 410 ,5 ,165, 20)

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

    ; Drivers left combo box
    _GUICtrlComboBox_BeginUpdate($to1)
    $iDriver = _GUICtrlComboBox_AddDir($to1, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to1)

    ; Drivers right combo box
    _GUICtrlComboBox_BeginUpdate($to2)
    $iDriver2 = _GUICtrlComboBox_AddDir($to2, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($to2)

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

    _ExpListView_SetFunction($hList1, '_Call_Function')
    _ExpListView_SetFunction($hList2, '_Call_Function')

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

    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Apsbutton
    Run("_aps.exe ")
    Case $UnApsbutton
    Run("_unaps.exe ")
    Case $GUI_EVENT_CLOSE, $exititem
    Exit
    EndSwitch
    WEnd

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

    Func _ToggleHidden($List)
    Static $bFlag1 = -1, $bFlag2 = -1

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

    Switch $List
    Case $hList1
    $bFlag1 *= -1
    If $bFlag1 = -1 Then Return False
    Case $hList2
    $bFlag2 *= -1
    If $bFlag2 = -1 Then Return False
    EndSwitch

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

    Return True

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

    EndFunc ;==>_ToggleHidden

    [/autoit]

    Hinweis zum Skript: Tool kann nur gestartet werden, wenn eine Disk in Laufwerk A:\ ist.!!!!