akurakkauaaa Posted June 13, 2011 Posted June 13, 2011 (edited) myFileListToArray_AllFiles is simple modification _FileListToArray for all fileswork for unicode: ą,ż,ć,ę,ń, ect...include:myFileListToArray_AllFiles.au3expandcollapse popup#include-once ; #FUNCTION# ==================================================================================================================== ; Name...........: myFileListToArray_AllFiles ; Description ...: Lists files and\or folders in a specified path ; Syntax.........: myFileListToArray_AllFiles($sPath[, $sFilter = "*.*"[, $iFlag = 1[, $full_adress = True[, $methody = 0[, $size_min = 0[, $size_max = 0[, $Accept_Attribute = 0[, $NO_Accept_Attribute = 0[, $LevelTooDown = 0]]]]\]]]]) ; Parameters ....: $sPath - Path to generate filelist for. ; $sFilter = [default is "*.*"]. The filter to use. Search the Autoit3 manual for the word "WildCards" For details, support now for multiple searches ; Example "*.exe; *.txt" will find all "*.exe" and "*.txt" files. ; '*' = 0 or more. '?' = 0 or 1. ; $iFlag = Optional: specifies whether to return files folders or both ; |$iFlag=0 Return both files and folders ; |$iFlag=1 (Default)Return files only ; |$iFlag=2 Return Folders only ; $full_adress = Optional: [default is true] ; |True - Return full adress for file ; |False - Return only file name ; $methody = Optional:[default is 1] search methody ; |$methody = 0 - simple ; |$methody = 1 - is full pattern ; $size_min = Optional:[default is 0] Minimal file size [MB] ; $size_max = Optional:[default is 0] Max file size [MB] ; $Accept_Attribute = Optional:[default is ""] Acccept only is file haw attributes. ; |"R" = READONLY ; |"A" = ARCHIVE ; |"S" = SYSTEM ; |"H" = HIDDEN ; |"N" = NORMAL ; |"D" = DIRECTORY ; |"O" = OFFLINE ; |"C" = COMPRESSED (NTFS compression, not ZIP compression) ; |"T" = TEMPORARY ; $NO_Accept_Attribute = Optional:[default is ""] NO acccept is file haw attributes. ; |"R" = READONLY ; |"A" = ARCHIVE ; |"S" = SYSTEM ; |"H" = HIDDEN ; |"N" = NORMAL ; |"D" = DIRECTORY ; |"O" = OFFLINE ; |"C" = COMPRESSED (NTFS compression, not ZIP compression) ; |"T" = TEMPORARY ; $LevelTooDown = Optional:[default is 0] how many level too down/up ; |0 = full tree (all files) ; |1 = search only one folder. ; |2 = 2 level down ; |3 = 3 level down ; |x = x level down ; |-1 = 1 level up (+ full tree) ; |-2 = 2 level up (+ full tree) ; |-x = x level up (+ full tree) ; Return values . : On Success - The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; @extended = How many files test ; On Failure - @Error = 1 - Path not found or invalid ; @Error = 2 - No File(s) Found ; @extended = How many files test ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: myFileListToArray_AllFiles ; Description ...: Zwraca liste plikow i/lub fodlderow ; Syntax.........: myFileListToArray_AllFiles($sPath[, $sFilter = "*.*"[, $iFlag = 1[, $full_adress = True[, $methody = 0[, $size_min = 0[, $size_max = 0[, $Accept_Attribute = 0[, $NO_Accept_Attribute = 0[, $LevelTooDown = 0]]]]]]]]]) ; Parameters ....: $sPath - Sciezka dostempu do pliku ; $sFilter = [default is "*.*"]. Filtr uzywany przy wyszukiwaniu. Mozna uzyc ich kilka oddzielajac kolejne znakiem ";" ; Naprzyklad skrut "*.exe; *.txt" zastapi dwa wyszukiwania "*.exe" i "*.txt". ; '*' = 0 lub wiecej. '?' = 0 lub 1. ; $iFlag = Optional: parametr ustalajacy czy zwracac tylko pliki, foldery, czy oba na raz. ; |$iFlag=0 Zwracaj wszystko ; |$iFlag=1 (Default)Zwracaj tylko pliki ; |$iFlag=2 Zwracaj tylko foldery ; $full_adress = [default is true] ; |True - Zwracaj pełny adress ; |False - Zwracaj tylko nazwe pliku ; $methody = [default is 1] - metoda szukania ; |$methody = 0 - metoda prosta (szukaj plik zawierajacy czesc podanej nazwy) ; |$methody = 1 - pelny pattern (to jest caly pattern) ; $size_min = [default is 0] Minimalny rozmiar pliku [MB] ; $size_max = [default is 0] maksymalny rozmiar pliku [MB] ; $Accept_Attribute = [default is ""] Akceptuj tylko te pliki co maja te atrybuty. ; |"R" = READONLY ; |"A" = ARCHIVE ; |"S" = SYSTEM ; |"H" = HIDDEN ; |"N" = NORMAL ; |"D" = DIRECTORY ; |"O" = OFFLINE ; |"C" = COMPRESSED (NTFS compression, not ZIP compression) ; |"T" = TEMPORARY ; $NO_Accept_Attribute = [default is ""] Nie akceptuj plikow z tymi atrybutami. ; |"R" = READONLY ; |"A" = ARCHIVE ; |"S" = SYSTEM ; |"H" = HIDDEN ; |"N" = NORMAL ; |"D" = DIRECTORY ; |"O" = OFFLINE ; |"C" = COMPRESSED (NTFS compression, not ZIP compression) ; |"T" = TEMPORARY ; $LevelTooDown = [default is 0] = Jak gleboko (poziom) szukac w dol/gore. ; |0 = cale drzewo (all files). ; |1 = Szukaj tylko w 1 folderze. ; |2 = 2 poziomy w dol. ; |3 = 3 poziomy w dol. ; |x = x poziomy w dol. ; |-1 = 1 poziom w gore (+ cale drzewo) ; |-2 = 2 poziom w gore (+ cale drzewo) ; |-x = x poziom w gore (+ cale drzewo) ; Return values . : On Success - Zwraca tablice wyników: ; $array[0] = Liczba znalezionych plikow i folderow ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; @extended = Ile plikow przeszukano na dysku ; On Niepowodzenie - @Error = 1 - Sciezka do katalogu jest bledna lub katalog nie istnieje ($sPath) ; @Error = 2 - Nie znaleziono plikow ; @extended = Ile plikow przeszukano na dysku ; =============================================================================================================================== Func myFileListToArray_AllFiles($sPath, $sFilter = "*.*", $iFlag = 1, $full_adress = 1, $methody = 1, $size_min = 0, $size_max = 0, $Accept_Attribute = 0, $NO_Accept_Attribute = 0, $LevelTooDown = 0) Local $hSearch, $sFile, $sFileList, $sDelim = "|", $HowManyFiles = 0, $aReturn $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash Local $c, $is_ok, $attrib, $FileSize, $lev, $levPath Local $foldery = '', $newFoldersSearch = '', $array_foldery, $extended, $a_Attribute, $NO_a_Attribute $iFlag = Number($iFlag) $full_adress = Number($full_adress) If $full_adress <> 0 Then $full_adress = 1 $methody = Number($methody) If $methody <> 0 Then $methody = 1 $size_min = Number($size_min * 100) / 100 $size_max = Number($size_max * 100) / 100 If $size_max - $size_min < 0 Then $size_max = 0 If $Accept_Attribute = Default Or $Accept_Attribute = -1 Or $Accept_Attribute = '' Or $Accept_Attribute = '0' Then $Accept_Attribute = 0 If $NO_Accept_Attribute = Default Or $NO_Accept_Attribute = -1 Or $NO_Accept_Attribute = '' Or $NO_Accept_Attribute = '0' Then $NO_Accept_Attribute = 0 If $Accept_Attribute Then $a_Attribute = StringSplit(StringRegExpReplace($Accept_Attribute, "[;, ]", ""), "", 3) If $NO_Accept_Attribute Then $NO_a_Attribute = StringSplit(StringRegExpReplace($NO_Accept_Attribute, "[;, ]", ""), "", 3) $LevelTooDown = Number($LevelTooDown) ; TREE - level up/down If $LevelTooDown > 0 Then StringReplace($sPath, '\', '\') $levPath = @extended - 2 ElseIf $LevelTooDown < 0 Then StringReplace($sPath, '\', '\') $levPath = @extended If $LevelTooDown <= $levPath Then $LevelTooDown = $levPath + $LevelTooDown If $LevelTooDown <= 0 Then $LevelTooDown = 1 $sPath = StringLeft($sPath, StringInStr($sPath, '\', 0, $LevelTooDown)) $LevelTooDown = 0 EndIf EndIf If Not FileExists($sPath) Then Return SetError(1, 0, '') $sFilter = StringRegExpReplace($sFilter, "\s*;\s*", "|") If ($sFilter = Default) or ($sFilter = -1) Or StringInStr("|" & $sFilter & "|", "|*.*|") Or StringInStr("|" & $sFilter & "|", "||") Then $sFilter = '(?i).*' Else If $methody = 0 Then ;$methody = 0 - "simple" $sFilter = StringReplace($sFilter, '*', '\E*\Q') $sFilter = StringReplace($sFilter, '?', '\E?\Q') $sFilter = StringReplace($sFilter, '.', '\E*[.]*\Q') $sFilter = StringReplace($sFilter, '|', '\E*|*\Q') $sFilter = '\Q' & $sFilter & '\E' $sFilter = StringReplace($sFilter, '\Q\E', '') $sFilter = StringReplace($sFilter, '*', '.*') $sFilter = StringReplace($sFilter, '?', '.?') $sFilter = '(?i).*' & $sFilter & '.*' $sFilter = StringRegExpReplace($sFilter, '([.][*]){2,}', '.*') Else ;$methody = 1 - "is full pattern" $sFilter = StringReplace($sFilter, '*', '\E*\Q') $sFilter = StringReplace($sFilter, '?', '\E?\Q') $sFilter = StringReplace($sFilter, '.', '\E[.]\Q') $sFilter = StringReplace($sFilter, '|', '\E|\Q') $sFilter = '\Q' & $sFilter & '\E' $sFilter = StringReplace($sFilter, '\Q\E', '') $sFilter = StringReplace($sFilter, '*', '.*') $sFilter = StringReplace($sFilter, '?', '.?') $sFilter = '(?i)' & $sFilter $sFilter = StringRegExpReplace($sFilter, '([.][*]){2,}', '.*') EndIf EndIf ;ConsoleWrite($sFilter & @CRLF) While 1 $hSearch = FileFindFirstFile($sPath & '*') If Not @error Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop $extended = @extended $HowManyFiles += 1 If $extended = 1 Then ;folder ;If $Accept_Attribute Or $NO_Accept_Attribute Then ;$attrib = FileGetAttrib($sPath & $sFile & '\') ;$is_ok = True ;If $Accept_Attribute Then ; test atrybutow - akceptowane ;For $c = 0 To UBound($a_Attribute) - 1 ;If Not StringInStr($attrib, $a_Attribute[$c]) Then $is_ok = False ;Next ;EndIf ;If $NO_Accept_Attribute Then ; test atrybutow - nie akceptowane ;For $c = 0 To UBound($NO_a_Attribute) - 1 ;If StringInStr($attrib, $NO_a_Attribute[$c]) Then $is_ok = False ;Next ;EndIf ;If $is_ok = False Then ContinueLoop ;EndIf If Not $LevelTooDown Then $newFoldersSearch &= $sPath & $sFile & '\' & $sDelim ;nowe foldery do szukania Else StringReplace($sPath & $sFile, '\', '\') $lev = @extended - $levPath If $LevelTooDown >= $lev Then $newFoldersSearch &= $sPath & $sFile & '\' & $sDelim EndIf EndIf EndIf If ($iFlag + $extended = 2) Then ContinueLoop $is_ok = Not StringRegExpReplace($sFile, $sFilter, '') ; test pattern If ($Accept_Attribute Or $NO_Accept_Attribute) And $is_ok Then ;test atrybutow $attrib = FileGetAttrib($sPath & $sFile) If $Accept_Attribute Then ; test atrybutow - akceptowane For $c = 0 To UBound($a_Attribute) - 1 If Not StringInStr($attrib, $a_Attribute[$c]) Then $is_ok = False Next EndIf If $NO_Accept_Attribute Then ; test atrybutow - nie akceptowane For $c = 0 To UBound($NO_a_Attribute) - 1 If StringInStr($attrib, $NO_a_Attribute[$c]) Then $is_ok = False Next EndIf EndIf If ($size_min Or $size_max) And $is_ok Then ; test size $FileSize = Round(FileGetSize($sPath & $sFile) / 1048576, 2) ; size = MB If $size_min And $size_min > $FileSize Then $is_ok = False If $size_max And $size_max < $FileSize Then $is_ok = False EndIf If $full_adress And $is_ok Then $sFileList &= $sDelim & $sPath & $sFile ElseIf Not $full_adress And $is_ok Then $sFileList &= $sDelim & $sFile EndIf WEnd EndIf FileClose($hSearch) $foldery = $newFoldersSearch & $foldery $newFoldersSearch = '' $array_foldery = StringSplit($foldery, $sDelim, 3) If UBound($array_foldery) <= 1 Then ExitLoop $foldery = StringTrimLeft($foldery, StringInStr($foldery, $sDelim)) $sPath = $array_foldery[0] WEnd If Not $sFileList Then Return SetError(2, $HowManyFiles, "") $aReturn = StringSplit(StringTrimLeft($sFileList, 1), $sDelim) $sFileList = 0 SetExtended($HowManyFiles) Return $aReturn EndFunc ;==>myFileListToArray_AllFiles ;############################################################## ; version 2 (only 4 parameters) ;############################################################## Func myFileListToArray_AllFilesEx($sPath, $sFilter = "*.*", $iFlag = 1, $full_adress = 1) Local $hSearch, $sFile, $sFileList, $sDelim = "|", $HowManyFiles = 0, $aReturn $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash Local $is_ok, $foldery = '', $newFoldersSearch = '', $array_foldery, $extended $iFlag = Number($iFlag) $full_adress = Number($full_adress) If $full_adress <> 0 Then $full_adress = 1 If Not FileExists($sPath) Then Return SetError(1, 0, '') $sFilter = StringRegExpReplace($sFilter, "\s*;\s*", "|") If ($sFilter = Default) or ($sFilter = -1) Or StringInStr("|" & $sFilter & "|", "|*.*|") Or StringInStr("|" & $sFilter & "|", "||") Then $sFilter = '(?i).*' Else $sFilter = StringReplace($sFilter, '*', '\E*\Q') $sFilter = StringReplace($sFilter, '?', '\E?\Q') $sFilter = StringReplace($sFilter, '.', '\E[.]\Q') $sFilter = StringReplace($sFilter, '|', '\E|\Q') $sFilter = '\Q' & $sFilter & '\E' $sFilter = StringReplace($sFilter, '\Q\E', '') $sFilter = StringReplace($sFilter, '*', '.*') $sFilter = StringReplace($sFilter, '?', '.?') $sFilter = '(?i)' & $sFilter $sFilter = StringRegExpReplace($sFilter, '([.][*]){2,}', '.*') EndIf ;ConsoleWrite($sFilter &@CRLF) While 1 $hSearch = FileFindFirstFile($sPath & '*') If Not @error Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop $extended = @extended $HowManyFiles += 1 If $extended = 1 Then ;folder $newFoldersSearch &= $sPath & $sFile & '\' & $sDelim ;nowe foldery do szukania EndIf If ($iFlag + $extended = 2) Then ContinueLoop $is_ok = Not StringRegExpReplace($sFile, $sFilter, '') ; test pattern If $full_adress And $is_ok Then $sFileList &= $sDelim & $sPath & $sFile ElseIf Not $full_adress And $is_ok Then $sFileList &= $sDelim & $sFile EndIf WEnd EndIf FileClose($hSearch) $foldery = $newFoldersSearch & $foldery $newFoldersSearch = '' $array_foldery = StringSplit($foldery, $sDelim, 3) If UBound($array_foldery) <= 1 Then ExitLoop $foldery = StringTrimLeft($foldery, StringInStr($foldery, $sDelim)) $sPath = $array_foldery[0] WEnd If Not $sFileList Then Return SetError(2, $HowManyFiles, "") $aReturn = StringSplit(StringTrimLeft($sFileList, 1), $sDelim) $sFileList = 0 SetExtended($HowManyFiles) Return $aReturn EndFunc ;==>myFileListToArray_AllFilesExexample v1:#include <Array.au3> #include 'myFileListToArray_AllFiles.au3' $array = myFileListToArray_AllFiles(@WindowsDir) _ArrayDisplay($array, 'all files') $array = myFileListToArray_AllFiles(@WindowsDir , '', 2) _ArrayDisplay($array, 'all folders') $array = myFileListToArray_AllFiles(@WindowsDir , '*.txt ; *.rtf') _ArrayDisplay($array , 'only: txt & rtf')example v2:expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include 'myFileListToArray_AllFiles.au3' ;Opt('MustDeclareVars', 1) Global $gui, $label, $label_2, $bution, $listview, $Input_Filter, $Input_MinSiz, $Input_MaxSiz Global $label_sPath, $label_filter, $label_3 Global $Input_Flag, $Input_Adress, $Input_methody, $Input_AccAtryb, $Input_NO_AccAtryb, $Imput_LevDown Global $szukane = "*.mp? ; *.wma ; *.wav; *.avi ; *.rmvb ; *.flv" ;Global $szukane = "*Au???t v* S*r?p*.au?" Global $title = 'myFileListToArray_AllFiles()' $gui = GUICreate($title, 920, 585, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetBkColor(0xF0F4F9) $label = GUICtrlCreateLabel($szukane, 10, 12, 590, 20) GUICtrlSetFont(-1, 12, 800) $Input_Filter = GUICtrlCreateInput($szukane, 10, 40, 380, 20) GUICtrlCreateLabel('* = 0 or more. ? = 0 or 1. ; = next pattern', 10, 60, 380, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0x0000ff) $bution = GUICtrlCreateButton("Search", 412, 36, 129, 25) $label_sPath = GUICtrlCreateLabel('$sPath = ', 715, 10, 200, 20, $SS_CENTERIMAGE) $label_filter = GUICtrlCreateLabel('$sFilter = ' & $szukane, 715, 40, 200, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('', 715, 70, 200, 3, $SS_SUNKEN) GUICtrlCreateLabel('$iFlag= 1 (Default) [Optional]', 715, 80, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_Flag = GUICtrlCreateInput('1', 715, 100, 40, 20, $ES_NUMBER + $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateLabel('0 = all, 1 = files, 2 = folders', 760, 100, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('$full_adress = 1 (Default is True) [Optional]', 715, 140, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_Adress = GUICtrlCreateInput('1', 715, 160, 40, 20, $ES_NUMBER + $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 1, 0) GUICtrlCreateLabel('0 = file name, 1 = full adress', 760, 160, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('$methody = 1 (Default) [Optional]', 715, 200, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_methody = GUICtrlCreateInput('1', 715, 220, 40, 20, $ES_NUMBER + $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 1, 0) GUICtrlCreateLabel('0 = simple, 1 = is full pattern', 760, 220, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('$size_min = 0 (Default) [Optional]', 715, 260, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_MinSiz = GUICtrlCreateInput('0', 715, 280, 40, 20, $ES_NUMBER) GUICtrlCreateLabel('minmal size [MB]', 760, 280, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('$size_max = 0 (Default) [Optional]', 715, 320, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_MaxSiz = GUICtrlCreateInput('0', 715, 340, 40, 20, $ES_NUMBER) GUICtrlCreateLabel('maxymal size [MB]', 760, 340, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('$Accept_Attribute = "" (Default) [Optional]', 715, 380, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_AccAtryb = GUICtrlCreateInput('', 715, 400, 40, 20) GUICtrlCreateLabel('accept attribute', 760, 400, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('attribute: R,A,S,H,N,D,O,C,T', 740, 420, 140, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0x0000ff) GUICtrlSetTip(-1, 'String returned could contain a combination of these letters "RASHNDOCT":' & @CRLF & _ '"R" = READONLY' & @CRLF & '"A" = ARCHIVE ' & @CRLF & '"S" = SYSTEM ' & @CRLF & '"H" = HIDDEN ' & @CRLF & _ '"N" = NORMAL ' & @CRLF & '"D" = DIRECTORY ' & @CRLF & '"O" = OFFLINE ' & @CRLF & _ '"C" = COMPRESSED (NTFS compression, not ZIP compression) ' & @CRLF & '"T" = TEMPORARY') GUICtrlCreateLabel('$NO_Accept_Attribute = "" (Default) [Optional]', 715, 450, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Input_NO_AccAtryb = GUICtrlCreateInput('', 715, 470, 40, 20) GUICtrlCreateLabel('NO accept attribute', 760, 470, 140, 20, $SS_CENTERIMAGE) GUICtrlCreateLabel('attribute: R,A,S,H,N,D,O,C,T', 740, 490, 140, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0x0000ff) GUICtrlSetTip(-1, 'String returned could contain a combination of these letters "RASHNDOCT":' & @CRLF & _ '"R" = READONLY' & @CRLF & '"A" = ARCHIVE ' & @CRLF & '"S" = SYSTEM ' & @CRLF & '"H" = HIDDEN ' & @CRLF & _ '"N" = NORMAL ' & @CRLF & '"D" = DIRECTORY ' & @CRLF & '"O" = OFFLINE ' & @CRLF & _ '"C" = COMPRESSED (NTFS compression, not ZIP compression) ' & @CRLF & '"T" = TEMPORARY') GUICtrlCreateLabel('$LevelTooDown = 0 (Default) [Optional]', 715, 520, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xff0000) $Imput_LevDown = GUICtrlCreateInput('0', 715, 540, 40, 20, $ES_NUMBER + $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateUpdown(-1) GUICtrlCreateLabel('0 = all, 1 = 1lev, x = xlev, ect', 760, 540, 200, 20, $SS_CENTERIMAGE) $label_2 = GUICtrlCreateLabel('"+" = tree level down, "-" = level up', 740, 560, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0x0000ff) GUICtrlSetTip(-1, 'how many level too down / up' & @CRLF & _ '0 = full tree (all files)' & @CRLF & _ '1 = search only one folder' & @CRLF & _ '2 = 2 level down' & @CRLF & _ '3 = 3 level down' & @CRLF & _ 'x = x level down' & @CRLF & _ '-1 = 1 level up (+ full tree)' & @CRLF & _ '-2 = 2 level up (+ full tree)' & @CRLF & _ '-x = x level up (+ full tree)') $listview = GUICtrlCreateListView("No|WYNIK WYSZUKIWANIA|Nazwa|Format|Size[MB]", 10, 80, 700, 480) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($listview, 0x101E, 0, 35) GUICtrlSendMsg($listview, 0x101E, 1, 350) GUICtrlSendMsg($listview, 0x101E, 2, 170) GUICtrlSendMsg($listview, 0x101E, 3, 60) GUICtrlSendMsg($listview, 0x101E, 4, 60) _GUICtrlListView_SetSelectedColumn($listview, 1) $label_3 = GUICtrlCreateLabel('speed: = = = = ', 20, 560, 200, 20, $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0x0000ff) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $bution Search_Files() EndSwitch Sleep(20) WEnd Func Search_Files() Local $mySave = IniRead(@ScriptDir & "\configbot.ini", "tester", "File Select", @ScriptDir) Local $var = FileSelectFolder("", '', "", $mySave, $gui) IniWrite(@ScriptDir & "\configbot.ini", "tester", "File Select", $var) Local $FileList Local $ile = 0 Local $Skrucona_Nazwa Local $format Local $rozmiar Local $mTimer Local $myExtended = 0 Local $i, $id Local $SEARCH = GUICtrlRead($Input_Filter) Local $myFlag = GUICtrlRead($Input_Flag) Local $myAdress = GUICtrlRead($Input_Adress) Local $myMethody = GUICtrlRead($Input_methody) Local $size_min = GUICtrlRead($Input_MinSiz) Local $size_max = GUICtrlRead($Input_MaxSiz) Local $myAccAtryb = GUICtrlRead($Input_AccAtryb) Local $myNOAccAtryb = GUICtrlRead($Input_NO_AccAtryb) Local $myLevTooDown = GUICtrlRead($Imput_LevDown) For $i = $Input_Filter To $label_2 GUICtrlSetState($i, $GUI_DISABLE) Next WinSetTitle($gui, "", $title & ' [ 0 / 0 ]') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($listview)) GUICtrlSetData($label, "Sprawdzam " & $var) GUICtrlSetData($label_sPath, '$sPath = ' & $var) GUICtrlSetData($label_3, 'test speed = START') ConsoleWrite(myConsoleWriteTXT($var, $SEARCH, $myFlag, $myAdress, $myMethody, $size_min, $size_max, $myAccAtryb, $myNOAccAtryb, $myLevTooDown)) $mTimer = TimerInit() $FileList = myFileListToArray_AllFiles($var, $SEARCH, $myFlag, $myAdress, $myMethody, $size_min, $size_max, $myAccAtryb, $myNOAccAtryb, $myLevTooDown) $myExtended = @extended GUICtrlSetData($label_3, 'test speed = ' & TimerDiff($mTimer) / 1000 & ' sek.') If IsArray($FileList) Then local $array_AD[UBound($FileList)-1][5] For $id = 1 To $FileList[0] $ile = $ile + 1 $Skrucona_Nazwa = StringRegExpReplace($FileList[$id], "((?:.*?[\\/]+)*)(.*?\z)", "$2") $format = StringRegExpReplace($FileList[$id], "((?:.*?[\\/.]+)*)(.*?\z)", "$2") If $format = $Skrucona_Nazwa Then $format = '' $rozmiar = Round(FileGetSize($FileList[$id]) / 1048576, 2) ;GUICtrlCreateListViewItem($ile & '|' & $FileList[$id] & '|' & $Skrucona_Nazwa & '|' & $format & '|' & $rozmiar, $listview) $array_AD[$id-1][0]= $ile $array_AD[$id-1][1]= $FileList[$id] $array_AD[$id-1][2]= $Skrucona_Nazwa $array_AD[$id-1][3]= $format $array_AD[$id-1][4]= $rozmiar ;WinSetTitle($gui, "", StringFormat(' [ [ %s / %s ] / %s ] %s', $ile, $FileList[0], $myExtended, $FileList[$id])) Next _GUICtrlListView_AddArray($listview, $array_AD) EndIf WinSetTitle($gui, "", ' [' & $ile & ' / ' & $myExtended & ' ] succes / all files') For $i = $Input_Filter To $label_2 GUICtrlSetState($i, $GUI_ENABLE) Next GUICtrlSetData($label, $SEARCH);'lista plikow') EndFunc ;==>Search_Files Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $listview If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $B_DESCENDING[_GUICtrlListView_GetColumnCount($listview)] _GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case GUICtrlGetHandle($Input_Filter) Switch $iCode Case $EN_UPDATE GUICtrlSetData($label_filter, '$sFilter = ' & GUICtrlRead($Input_Filter)) EndSwitch EndSwitch EndFunc ;==>WM_COMMAND Func myConsoleWriteTXT($pth, $flt, $flg, $adr, $meth, $min, $max, $Acpt, $NOacpt, $LevD) If $max - $min < 0 Then $max = 0 If $LevD <> 0 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s, %s, %s, "%s", "%s", %s)', _ $pth, $flt, $flg, $adr, $meth, $min, $max, $Acpt, $NOacpt, $LevD) & @CRLF If $NOacpt <> '' Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s, %s, %s, "%s", "%s")', _ $pth, $flt, $flg, $adr, $meth, $min, $max, $Acpt, $NOacpt) & @CRLF If $Acpt <> '' Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s, %s, %s, "%s")', _ $pth, $flt, $flg, $adr, $meth, $min, $max, $Acpt) & @CRLF If $max <> 0 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s, %s, %s)', _ $pth, $flt, $flg, $adr, $meth, $min, $max) & @CRLF If $min <> 0 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s, %s)', _ $pth, $flt, $flg, $adr, $meth, $min) & @CRLF If $meth <> 1 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s, %s)', _ $pth, $flt, $flg, $adr, $meth) & @CRLF If $adr <> 1 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s, %s)', _ $pth, $flt, $flg, $adr) & @CRLF If $flg <> 1 Then Return StringFormat('myFileListToArray_AllFiles("%s", "%s", %s)', _ $pth, $flt, $flg) & @CRLF If $flt = '*.*' Or $flt = '*' Or $flt = '' Then Return StringFormat('myFileListToArray_AllFiles("%s")', _ $pth) & @CRLF Return StringFormat('myFileListToArray_AllFiles("%s", "%s")', _ $pth, $flt) & @CRLF EndFunc ;==>myConsoleWriteTXTnajprostsze.au3myFileListToArray_AllFiles.au3tester funkcji.au3 Edited August 7, 2011 by akurakkauaaa my crap: myFileListToArray_AllFiles, SciTE Helper, myImageSearch
akurakkauaaa Posted August 6, 2011 Author Posted August 6, 2011 //1 post edit: simple modification. more options for search. np: *Au???t v* S*r?p*.au? my crap: myFileListToArray_AllFiles, SciTE Helper, myImageSearch
AZJIO Posted April 19, 2012 Posted April 19, 2012 akurakkauaaa example v2 Local $var = FileSelectFolder("", '', "", $mySave, $gui) If @error Then Return ; <<< add My other projects or all
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now