Hallo, ich erhalte seit der rekursiven Suche immer einen doppelten Pfadeintrag im ListView..
Ich sehe den Wald vor lauter Bäumen nicht mehr.
Seht ihr meinen Fehler?
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=U:\Azubi - Entwicklungen\Suche - Kolling\shell32_135.ico
#AutoIt3Wrapper_Res_Description=Suche für den Aktenplan
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1031
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
Script Function:
#author: Björn Alles
Programm zur Ordnersuche
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Includes
[/autoit] [autoit][/autoit] [autoit]#include <File.au3>
#include <Date.au3>
#include <Misc.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <RecFileListToArray.au3>
; Variablendeklaration:
[/autoit] [autoit][/autoit] [autoit]$version = "1.0"
$name = "Suchsoftware"
$quellpfad = @ScriptDir
$Debug_LV = False
Local $aFileList[1]
Local $hListView
Local $typ
; Hotkeys definieren
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ENTER}", "Suchen")
HotKeySet("^{End}","Ende")
; TrayIcon anzeigen
[/autoit] [autoit][/autoit] [autoit]Opt("TrayIconHide", 0)
Opt("TrayMenuMode", 1)
TraySetIcon("Shell32.dll", 23)
TraySetToolTip($name & " ist AKTIV / Strg+Ende zum Beenden")
;------- Programmstart --------
[/autoit] [autoit][/autoit] [autoit];Erstellung der Start-GUI
[/autoit] [autoit][/autoit] [autoit]$start = GUICreate("Auf der Spur...", 1200, 279, 128, 160)
GUISetIcon("C:\Windows\System32\shell32.dll", -172)
GUISetBkColor(0xA6CAF0)
$slabel_1 = GUICtrlCreateLabel("Quelle:",18 ,40, 104, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$slabel_2 = GUICtrlCreateLabel("Suchbegriff:", 18, 110, 104, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$sinput_1 = GUICtrlCreateInput($quellpfad, 18, 69, 215, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
$sinput_2 = GUICtrlCreateInput("", 18, 139, 215, 21)
$sbutton_1 = GUICtrlCreateButton("Neu", 246, 51, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Windows\System32\shell32.dll", -46)
$sbutton_3 = GUICtrlCreateButton("", 246, 121, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Windows\System32\shell32.dll", -23, 0)
$hListView = GUICtrlCreateListView("", 320, 0, 800, 273)
$Datei = GUICtrlCreateRadio("Datei", 128, 210, 65, 17)
$Ordner = GUICtrlCreateRadio("Ordner", 40, 210, 65, 17)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUICtrlSetState($ordner,$GUI_CHECKED)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
[/autoit] [autoit][/autoit] [autoit]Case $msg = $GUI_EVENT_CLOSE ;Programm beenden
Exit
Case $msg = $sbutton_1 ;Quellpfad über Navigationsfenster wählen
[/autoit] [autoit][/autoit] [autoit]$quellpfad2 = FileSelectFolder("Bitte den Ordner angeben in dem die Dateien gesucht werden sollen:", "", "2", $quellpfad)
If @error Then
GUICtrlSetData($sinput_1, $quellpfad )
Else
GUICtrlSetData($sinput_1, $quellpfad2 )
EndIf
Case $msg = $sbutton_3 ;Weiter zur Suche (StartGUI verlassen)
[/autoit] [autoit][/autoit] [autoit];Selektion der Dokumente und Wartebildschirm
[/autoit] [autoit][/autoit] [autoit]_GUICtrlListView_DeleteColumn($hListView,0)
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($datei) = $GUI_CHECKED Then
$typ = "1"
Elseif guictrlread($ordner) = $gui_checked then
$typ = "2"
EndIf
$fpath = GUICtrlRead($sinput_1 & "\")
[/autoit] [autoit][/autoit] [autoit]If GUICtrlRead($sinput_2) = "" Then
$input_2 = "*"
Else
$input_2 = GUICtrlRead($sinput_2)
EndIf
$search = $input_2
Local $aFileList[1]
$fFileList = _RecFileListToArray($fpath,"*" & $input_2 & "*",$typ,1,1,2)
If IsArray($fFileList) Then
$prev = UBound($aFileList)-1
ReDim $aFileList[$prev+1+$fFileList[0]]
For $j = 1 To $fFileList[0]
$aFileList[$prev+$j] = $fpath & $fFileList[$j]
Next
EndIf
;Übergabe an Ergebnisausgabe oder Errorhandling
If $aFileList = 0 then
msgbox(0, $name, "Es wurden keine Dokumente nach Ihren Vorgaben gefunden.")
Else
_GUICtrlListView_DeleteAllItems($hListView)
_Result()
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]EndSelect
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit]Func _Result()
[/autoit] [autoit][/autoit] [autoit]sleep(100)
_GUICtrlListView_InsertColumn($hListView, 0, "Dateiname", 1000)
; Ergänze Listeneinträge
[/autoit] [autoit][/autoit] [autoit]For $n = 1 to UBound($aFileList) -1
_GUICtrlListView_AddItem($hListView, $aFileList[$n], 0)
Next
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $iIDFrom
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
ShellExecute($aFileList[DllStructGetData($tInfo, "Index")+1])
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func Suchen()
If WinActive("[CLASS:AutoIt v3 GUI]") Then $msg = $sbutton_3
EndFunc
Func Ende()
Exit
EndFunc