Loc Posted September 17, 2021 Share Posted September 17, 2021 I found a lot of questions about comparing the difference between 2 images so I came up with the idea to compare and circle the difference but didn't know where to start. Looking for help and direction Link to comment Share on other sites More sharing options...
Zedna Posted September 17, 2021 Share Posted September 17, 2021 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Loc Posted September 17, 2021 Author Share Posted September 17, 2021 I have looked and found the answer as the solution but my udf download path is broken 😰 Leendert-Jan 1 Link to comment Share on other sites More sharing options...
Zedna Posted September 17, 2021 Share Posted September 17, 2021 Here is prospeed.dll for you. Whole original ZIP is too big to post here, I will post it later today on some host server ... ProSpeed-dll.zip Loc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Trong Posted September 17, 2021 Share Posted September 17, 2021 prospeed3.0.rar Loc 1 Regards, Link to comment Share on other sites More sharing options...
Loc Posted September 18, 2021 Author Share Posted September 18, 2021 I looked in the udf and didn't see the CompareBytes function Link to comment Share on other sites More sharing options...
Nine Posted September 18, 2021 Share Posted September 18, 2021 Just load the 2 pictures with GDI+. Use _GDIPlus_BitmapLockBits (see example) on the 2 pictures then compare integer (32 bits) by integer. If pictures are of different sizes, then resize them with _GDIPlus_ImageResize beforehand... Loc 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Zedna Posted September 18, 2021 Share Posted September 18, 2021 As I promised, here it is: https://ulozto.net/file/f4RXDYHMtOcP/prospeed-ziphttps://ulozto.net/file/3UKjU2kfEQ66/prospeed-dll-ziphttps://ulozto.net/file/UKTdtv6AhY2G/demos-and-sourcecodes-autoit-zip robertocm, Werty and Loc 1 2 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
KaFu Posted October 14, 2022 Share Posted October 14, 2022 Over a year old, but I was looking into this myself, so here's a working sample for "CompareBytes" applied to two bitmaps, really fast. Different Bytes = 1432 Difference in % = 0.0476951771915801 Bytes tested = 3002400 Tolerance = 0 Timer = 33.8626 expandcollapse popup#include <GDIPlus.au3> _GDIPlus_Startup() Local $iTimer = TimerInit() Local $width1, $height1, $stride1, $pbitmap1 Local $Bitmap1 = getbmpdata(@ScriptDir & "\test_1.jpg", $width1, $height1, $stride1, $pbitmap1) Local $width2, $height2, $stride2, $pbitmap2 Local $Bitmap2 = getbmpdata(@ScriptDir & "\test_2.jpg", $width2, $height2, $stride2, $pbitmap2) Local $i_Bitmap2_Size = DllStructGetSize($Bitmap2) Local $iBytesToTest = DllStructGetSize($Bitmap1) If $i_Bitmap2_Size > $iBytesToTest Then $iBytesToTest = $i_Bitmap2_Size Local $iTolerance = 0 $iRes = DllCall(@ScriptDir & "\ProSpeed3.0.dll", "long", "CompareBytes", "long", DllStructGetPtr($Bitmap1), "long", DllStructGetPtr($Bitmap2), "long", $iBytesToTest, "long", $iTolerance) ConsoleWrite("Different Bytes" & @TAB & " = " & $iRes[0] & @CRLF) ; Ergebniss: Long - 0 bei kompletter Übereinstimmung, ansonsten Anzahl verschiedener Bytes. ConsoleWrite("Difference in %" & @TAB & " = " & $iRes[0] / $iBytesToTest * 100 & @CRLF) ConsoleWrite("Bytes tested" & @TAB & " = " & $iBytesToTest & @CRLF) ConsoleWrite("Tolerance" & @TAB & " = " & $iTolerance & @CRLF) ConsoleWrite("Timer" & @TAB & @TAB & " = " & TimerDiff($iTimer) & @CRLF) _GDIPlus_ImageDispose($pbitmap1) _GDIPlus_ImageDispose($pbitmap2) _GDIPlus_Shutdown() Func getbmpdata($bmpfile, ByRef $width, ByRef $height, ByRef $stride, ByRef $pbitmap) ;returns a struct with the data of the pixel ; by AndyG ; https://www.autoitscript.com/forum/topic/106815-bitblt-picture-compare-count-difference/?do=findComment&comment=753998 $pbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile) ;_GDIPlus_BitmapLockBits gibt $tagGDIPBITMAPDATA-Struktur zurück $BitmapData = _GDIPlus_BitmapLockBits($pbitmap, 0, 0, _GDIPlus_ImageGetWidth($pbitmap), _GDIPlus_ImageGetHeight($pbitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) If @error Then MsgBox(0, "", "Error locking region " & @error) $stride = DllStructGetData($BitmapData, "Stride") ;Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $width = DllStructGetData($BitmapData, "Width") ;Image width - Number of pixels in one scan line of the bitmap. $height = DllStructGetData($BitmapData, "Height") ;Image height - Number of scan lines in the bitmap. ;$pixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0") ;Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixeldata = DllStructCreate("ubyte[" & (Abs($stride) * ($height)) & "]", $Scan0) $BMPData = DllStructGetData($pixeldata, 1) _GDIPlus_BitmapUnlockBits($pbitmap, $BMPData) ; _WinAPI_DeleteObject($pbitmap) ;_GDIPlus_ImageDispose($pBitmap) ;destroys the pixeldatastruct, have to be done at end of the script! Return $pixeldata EndFunc ;==>getbmpdata Parsix 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
KaFu Posted October 15, 2022 Share Posted October 15, 2022 Small correction, $iBytesToTest must be set to the smaller of the two values, not the larger one (otherwise it crashes, I guess due to trying to access unallocated memory). expandcollapse popup#include <Array.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Local $sFileSelectFolder = FileSelectFolder("Select a folder", @ScriptDir, 7) Local $a_FileList = _FileListToArrayXT($sFileSelectFolder, "*.bmp;*.jpg;*.jpeg;*.png;*.gif", 1, 2, False) ; _ArrayDisplay($a_FileList) For $i = $a_FileList[0] To 2 Step -1 _CompareBytes_Bitmaps($a_FileList[$i], $a_FileList[$i - 1]) Next _GDIPlus_Shutdown() Func _CompareBytes_Bitmaps($sFile1, $sFile2) ConsoleWrite("$sFile1= " & $sFile1 & @CRLF) ConsoleWrite("$sFile2= " & $sFile2 & @CRLF) Local $iTimer = TimerInit() Local $width1, $height1, $stride1, $pbitmap1 Local $Bitmap1 = _GetBitmap_PixelData($sFile1, $width1, $height1, $stride1, $pbitmap1) Local $width2, $height2, $stride2, $pbitmap2 Local $Bitmap2 = _GetBitmap_PixelData($sFile2, $width2, $height2, $stride2, $pbitmap2) Local $i_Bitmap2_Size = DllStructGetSize($Bitmap2) Local $iBytesToTest = DllStructGetSize($Bitmap1) If $i_Bitmap2_Size < $iBytesToTest Then $iBytesToTest = $i_Bitmap2_Size Local $iTolerance = 0 Local $iRes = DllCall(@ScriptDir & "\ProSpeed3.0.dll", "long", "CompareBytes", "long", DllStructGetPtr($Bitmap1), "long", DllStructGetPtr($Bitmap2), "long", $iBytesToTest, "long", $iTolerance) ConsoleWrite("Different Bytes" & @TAB & " = " & $iRes[0] & @CRLF) ; Ergebniss: Long - 0 bei kompletter Übereinstimmung, ansonsten Anzahl verschiedener Bytes. ConsoleWrite("Difference in %" & @TAB & " = " & $iRes[0] / $iBytesToTest * 100 & @CRLF) ConsoleWrite("Bytes tested" & @TAB & " = " & $iBytesToTest & @CRLF) ConsoleWrite("Tolerance" & @TAB & " = " & $iTolerance & @CRLF) ConsoleWrite("Timer" & @TAB & @TAB & " = " & TimerDiff($iTimer) & @CRLF & @CRLF) _GDIPlus_ImageDispose($pbitmap1) _GDIPlus_ImageDispose($pbitmap2) EndFunc ;==>_CompareBytes_Bitmaps Func _GetBitmap_PixelData($bmpfile, ByRef $width, ByRef $height, ByRef $stride, ByRef $pbitmap) ;returns a struct with the data of the pixel ; by AndyG ; https://www.autoitscript.com/forum/topic/106815-bitblt-picture-compare-count-difference/?do=findComment&comment=753998 $pbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile) ;_GDIPlus_BitmapLockBits gibt $tagGDIPBITMAPDATA-Struktur zurück Local $BitmapData = _GDIPlus_BitmapLockBits($pbitmap, 0, 0, _GDIPlus_ImageGetWidth($pbitmap), _GDIPlus_ImageGetHeight($pbitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) If @error Then MsgBox(0, "", "Error locking region " & @error) $stride = DllStructGetData($BitmapData, "Stride") ;Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $width = DllStructGetData($BitmapData, "Width") ;Image width - Number of pixels in one scan line of the bitmap. $height = DllStructGetData($BitmapData, "Height") ;Image height - Number of scan lines in the bitmap. ;$pixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap Local $Scan0 = DllStructGetData($BitmapData, "Scan0") ;Scan0 - Pointer to the first (index 0) scan line of the bitmap. Local $pixeldata = DllStructCreate("ubyte[" & (Abs($stride) * ($height)) & "]", $Scan0) Local $BMPData = DllStructGetData($pixeldata, 1) _GDIPlus_BitmapUnlockBits($pbitmap, $BMPData) ; _WinAPI_DeleteObject($pbitmap) ;_GDIPlus_ImageDispose($pBitmap) ;destroys the pixeldatastruct, have to be done at end of the script! Return $pixeldata EndFunc ;==>_GetBitmap_PixelData ; #FUNCTION# =========================================================================================== ; Name: _FileListToArrayXT ; Description: Lists files and\or folders in specified path(s) (Similar to using Dir with the /B Switch) ; additional features: multi-path, multi-filter, multi-exclude-filter, path format options, recursive search ; Syntax: _FileListToArrayXT([$sPath = @ScriptDir, [$sFilter = "*", [$iRetItemType, [$bRecursive = False, [$sExclude = "", [$iRetFormat = 1]]]]]]) ; Parameter(s): $sPath = optional: Search path(s), semicolon delimited (default: @ScriptDir) ; (Example: "C:\Tmp;D:\Temp") ; $sFilter = optional: Search filter(s), semicolon delimited . Wildcards allowed. (default: "*") ; (Example: "*.exe;*.txt") ; $iRetItemType = Include in search: 0 = Files and Folder, 1 = Files Only, 2 = Folders Only ; $iRetPathType = Returned element format: 0 = file/folder name only, 1 = relative path, 2 = full path ; $bRecursive = optional: True: recursive search including all subdirectories ; False (default): search only in specified folder ; $sExclude = optional: Exclude filter(s), semicolon delimited. Wildcards allowed. ; (Example: "Unins*" will remove all files/folders that begin with "Unins") ; $iRetFormat = optional: return format ; 0 = one-dimensional array, 0-based ; 1 = one-dimensional array, 1-based (default) ; 2 = String ( "|" delimited) ; Requirement(s): AutoIt Version 3.3.1.1 or newer ; Return Value(s): on success: 1-based or 0-based array or string (dependent on $iRetFormat) ; If no path is found, @error and @extended are set to 1, returns empty string ; If no filter is found, @error and @extended are set to 2, returns empty string ; If $iRetFormat is invalid, @error and @extended are set to 3, returns empty string ; If no data is found, @error and @extended are set to 4, returns empty string ; Author(s): Half the AutoIt Community ; ==================================================================================================== Func _FileListToArrayXT($sPath = @ScriptDir, $sFilter = "*", $iRetItemType = 0, $iRetPathType = 0, $bRecursive = False, $sExclude = "", $iRetFormat = 1) Local $hSearchFile, $sFile, $sFileList, $sWorkPath, $sRetPath, $iRootPathLen, $iPCount, $iFCount, $fDirFlag ;[check and prepare parameters] ;--------------- If $sPath = -1 Or $sPath = Default Then $sPath = @ScriptDir ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons $sPath = StringRegExpReplace(StringRegExpReplace($sPath, "(\s*;\s*)+", ";"), "\A;|;\z", "") ;check that at least one path is set If $sPath = "" Then Return SetError(1, 1, "") ;----- If $sFilter = -1 Or $sFilter = Default Then $sFilter = "*" ;prepare filter ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons $sFilter = StringRegExpReplace(StringRegExpReplace($sFilter, "(\s*;\s*)+", ";"), "\A;|;\z", "") ;check for invalid chars or that at least one filter is set If StringRegExp($sFilter, "[\\/><:\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") If $bRecursive Then ;Convert $sFilter for Regular Expression $sFilter = StringRegExpReplace($sFilter, '([\Q\.+[^]$(){}=!\E])', '\\$1') $sFilter = StringReplace($sFilter, "?", ".") $sFilter = StringReplace($sFilter, "*", ".*?") $sFilter = "(?i)\A(" & StringReplace($sFilter, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings ;$sFilter = "(?i)\A" & StringReplace($sFilter, ";", "|") & "\z" EndIf ;----- If $iRetItemType <> "1" And $iRetItemType <> "2" Then $iRetItemType = "0" ;----- If $iRetPathType <> "1" And $iRetPathType <> "2" Then $iRetPathType = "0" ;----- $bRecursive = ($bRecursive = "1") ;----- If $sExclude = -1 Or $sExclude = Default Then $sExclude = "" If $sExclude Then ;prepare $sExclude ;strip leading/trailing spaces and semi-colons, all adjacent semi-colons, and spaces surrounding semi-colons $sExclude = StringRegExpReplace(StringRegExpReplace($sExclude, "(\s*;\s*)+", ";"), "\A;|;\z", "") ;Convert $sExclude for Regular Expression $sExclude = StringRegExpReplace($sExclude, '([\Q\.+[^]$(){}=!\E])', '\\$1') $sExclude = StringReplace($sExclude, "?", ".") $sExclude = StringReplace($sExclude, "*", ".*?") $sExclude = "(?i)\A(" & StringReplace($sExclude, ";", "$|") & "$)" ;case-insensitive, convert ';' to '|', match from first char, terminate strings ;$sExclude = "(?i)\A" & StringReplace($sExclude, ";", "|") & "\z" EndIf ;----- ;If $iRetFormat <> "0" And $iRetFormat <> "2" Then $iRetFormat = "1" If Not ($iRetItemType = 0 Or $iRetItemType = 1 Or $iRetItemType = 2) Then Return SetError(3, 3, "") ;--------------- ;[/check and prepare parameters] ;--------------- Local $aPath = StringSplit($sPath, ';', 1) ;paths array Local $aFilter = StringSplit($sFilter, ';', 1) ;filters array ;--------------- If $bRecursive Then ;different handling for recursion (strategy: unfiltered search for all items and filter unwanted) If $sExclude Then ;different handling dependent on $sExclude parameter is set or not For $iPCount = 1 To $aPath[0] ;Path loop $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash If Not FileExists($sPath) Then ContinueLoop $iRootPathLen = StringLen($sPath) - 1 Local $aPathStack[1024] = [1, $sPath] While $aPathStack[0] > 0 $sWorkPath = $aPathStack[$aPathStack[0]] $aPathStack[0] -= 1 ;----- $hSearchFile = FileFindFirstFile($sWorkPath & '*') If @error Then ContinueLoop ;----- Switch $iRetPathType Case 2 ;full path $sRetPath = $sWorkPath Case 1 ;relative path $sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1) EndSwitch ;----- Switch $iRetItemType Case 1 While True ;Files only $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf $fDirFlag = @extended If $fDirFlag Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" ContinueLoop EndIf If StringRegExp($sFile, $sExclude) Then ContinueLoop If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd Case 2 While True ;Folders only $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf $fDirFlag = @extended If StringRegExp($sFile, $sExclude) Then ContinueLoop If $fDirFlag Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf EndIf WEnd Case Else While True ;Files and Folders $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf $fDirFlag = @extended If StringRegExp($sFile, $sExclude) Then ContinueLoop If $fDirFlag Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" EndIf If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd EndSwitch ;----- WEnd FileClose($hSearchFile) Next ;$iPCount - next path Else ;If Not $sExclude For $iPCount = 1 To $aPath[0] ;Path loop $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash If Not FileExists($sPath) Then ContinueLoop $iRootPathLen = StringLen($sPath) - 1 Local $aPathStack[1024] = [1, $sPath] While $aPathStack[0] > 0 $sWorkPath = $aPathStack[$aPathStack[0]] $aPathStack[0] -= 1 ;----- $hSearchFile = FileFindFirstFile($sWorkPath & '*') If @error Then ContinueLoop ;----- Switch $iRetPathType Case 2 ;full path $sRetPath = $sWorkPath Case 1 ;relative path $sRetPath = StringTrimLeft($sWorkPath, $iRootPathLen + 1) EndSwitch ;----- Switch $iRetItemType Case 1 While True ;Files only $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" ContinueLoop EndIf If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd Case 2 While True ;Folders only $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf EndIf WEnd Case Else While True ;Files and Folders $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then $aPathStack[0] += 1 If UBound($aPathStack) <= $aPathStack[0] Then ReDim $aPathStack[UBound($aPathStack) * 2] $aPathStack[$aPathStack[0]] = $sWorkPath & $sFile & "\" EndIf If StringRegExp($sFile, $sFilter) Then $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd EndSwitch ;----- WEnd FileClose($hSearchFile) Next ;$iPCount - next path EndIf ;If $sExclude Else ;If Not $bRecursive (strategy: filtered search for items) If $sExclude Then ;different handling dependent on $sExclude parameter is set or not For $iPCount = 1 To $aPath[0] ;Path loop $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash If Not FileExists($sPath) Then ContinueLoop ;----- Switch $iRetPathType Case 2 ;full path $sRetPath = $sPath Case 1 ;relative path $sRetPath = "" EndSwitch For $iFCount = 1 To $aFilter[0] ;filter loop ;----- $hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount]) If @error Then ContinueLoop ;----- Switch $iRetItemType Case 1 ;files Only While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then ContinueLoop ;bypass folder ;check for exclude files If StringRegExp($sFile, $sExclude) Then ContinueLoop $sFileList &= $sRetPath & $sFile & "|" WEnd Case 2 ;folders Only While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then ;bypass file ;check for exclude folder If StringRegExp($sFile, $sExclude) Then ContinueLoop $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd Case Else ;files and folders While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf ;check for exclude files/folder If StringRegExp($sFile, $sExclude) Then ContinueLoop $sFileList &= $sRetPath & $sFile & "|" WEnd EndSwitch FileClose($hSearchFile) Next ;$iFCount - next filter Next ;$iPCount - next path Else ;If Not $sExclude For $iPCount = 1 To $aPath[0] ;Path loop $sPath = StringRegExpReplace($aPath[$iPCount], "[\\/]+\z", "") & "\" ;ensure exact one trailing slash If Not FileExists($sPath) Then ContinueLoop ;----- Switch $iRetPathType Case 2 ;full path $sRetPath = $sPath Case 1 ;relative path $sRetPath = "" EndSwitch For $iFCount = 1 To $aFilter[0] ;filter loop ;----- $hSearchFile = FileFindFirstFile($sPath & $aFilter[$iFCount]) If @error Then ContinueLoop ;----- Switch $iRetItemType Case 1 ;files Only While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then ContinueLoop ;bypass folder $sFileList &= $sRetPath & $sFile & "|" WEnd Case 2 ;folders Only While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf If @extended Then ;bypass file $sFileList &= $sRetPath & $sFile & "|" EndIf WEnd Case Else ;files and folders While True $sFile = FileFindNextFile($hSearchFile) If @error Then FileClose($hSearchFile) ExitLoop EndIf $sFileList &= $sRetPath & $sFile & "|" WEnd EndSwitch FileClose($hSearchFile) Next ;$iFCount - next filter Next ;$iPCount - next path EndIf ;If $sExclude EndIf ;If $bRecursive ;--------------- FileClose($hSearchFile) ;set according return value If $sFileList Then Switch $iRetFormat Case 2 ;return a delimited string Return StringTrimRight($sFileList, 1) Case 0 ;return a 0-based array Return StringSplit(StringTrimRight($sFileList, 1), "|", 2) Case Else ;return a 1-based array Return StringSplit(StringTrimRight($sFileList, 1), "|", 1) EndSwitch Else Return SetError(4, 4, "") EndIf EndFunc ;==>_FileListToArrayXT OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
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