ZystemsK Posted April 13, 2009 Share Posted April 13, 2009 I'm using a modified version of the MultiFileCopy to do some simple backups. The problem I'm running into is that the text isn't clearing properly.I'm working on making it use tabs for different programs. Currently, it's just a hack job until I tidy it up and remove redundant code. Here's the code:expandcollapse popup#include<String.au3> #include<Misc.au3> #include<File.au3> #include<Array.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #Region ### START Koda GUI section ### Form=C:\Koda\Forms\test.kxf $Form1 = GUICreate('MultiFileCopy', 633, 500, -1, -1, -1) $Tab1 = GUICtrlCreateTab(32, 40, 537, 369) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Backup1") $Label1 = GUICtrlCreateLabel("Data Backup1", 41, 78, 202, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $Progress2 = GUICtrlCreateProgress(48, 340, 460, 20) $Progress1 = GUICtrlCreateProgress(48, 244, 460, 20) $Label3 = GUICtrlCreateLabel("", 48, 120, 340, 84) GUICtrlSetFont(-1, 10, 400, 0, 'Courier New') $Button1 = GUICtrlCreateButton("Cancel", 448, 368, 75, 25) GUICtrlSetFont(-1, 9, 400, 0, 'Arial') $Button2 = GUICtrlCreateButton("Backup", 88, 368, 75, 25) GUICtrlSetFont(-1, 9, 400, 0, 'Arial') $Input1 = GUICtrlCreateInput("", 400, 144, 121, 21) $Label8 = GUICtrlCreateLabel("Directory:", 400, 120, 92, 17) GUICtrlSetFont(-1, 10, 400, 0, 'Courier New') $Label4 = GUICtrlCreateLabel("File:", 48, 213, 60, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label5 = GUICtrlCreateLabel("0 %", 120, 213, 53, 25) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label6 = GUICtrlCreateLabel("Total:", 48, 304, 60, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label7 = GUICtrlCreateLabel("0 %", 120, 304, 390, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $TabSheet2 = GUICtrlCreateTabItem("Backup2") $Label2 = GUICtrlCreateLabel("Backup2", 41, 78, 145, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $Progress3 = GUICtrlCreateProgress(48, 244, 486, 17) $Progress4 = GUICtrlCreateProgress(48, 340, 486, 17) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("E&xit", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("&Help") $MenuItem4 = GUICtrlCreateMenuItem("&About", $MenuItem3) GUISetState() #EndRegion ### END Koda GUI section ### Global $strFiles = '', $strSize = 0, $strDatList[500], $strIdxList, $strFileList, $backupdir $source = "c:\test\" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $backupdir = $source & "SDBackup-" & @MON & "-" & @MDAY & "-" & @YEAR $strFileList = FileFindFirstFile($source & "*.dat") If NOT @Error Then $i=1 While 1 $sFile = FileFindNextFile($strFileList) If @Error Then $strDatList[0] = $i-1 ExitLoop EndIf $strDatList[$i] = $source & $sFile $i += 1 WEnd EndIf FileClose($strFileList) Global $aReturn = _MultiFileCopy($strDatList, $backupdir, False) EndSwitch WEnd Func _MultiFileCopy($aSource, $sDestPath = '', $bOverWrite = True, $sPreFix = '') Local $aMFC[12] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, DllOpen('user32.dll')] Global $oldGUICloseOnESC = Opt('GUICloseOnESC', 0) Global $ret, $sShowSource, $sShowDest, $sSourcePath = '', $sNewFolder = '', $k __ProgressCreate($aMFC) If IsArray($aSource) Then If Not IsNumber($aSource[0]) Then Return SetError(1, 0, 0) For $i = 1 To $aSource[0] $aMFC[7] += FileGetSize($aSource[$i]) Next If $sDestPath = '' Then Return SetError(0, 0, 1) EndIf If StringRight($sDestPath, 1) <> '\' Then $sDestPath &= '\' If Not FileExists($sDestPath) Then If Not DirCreate($sDestPath) Then Return SetError(2, 0, 0) EndIf $sShowDest = StringRegExpReplace($sDestPath, '(.{15})(.*)(.{35})', '$1' & '[...]' & '$3') Global $aReturn = $aSource Global $callback = DllCallbackRegister('__Progress', 'int', 'uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;str') Global $ptr = DllCallbackGetPtr($callback) Global $DllKernel32 = DllOpen('kernel32.dll') $aMFC[9] = TimerInit() For $i = 1 To $aSource[0] $sArray = '' For $j = 0 To 11 $sArray &= $aMFC[$j] & ';' Next $sFile = StringMid($aSource[$i], StringInStr($aSource[$i], '\', 0, -1) + 1) If $sSourcePath <> '' Then $sNewFolder = StringTrimLeft(StringLeft($aSource[$i], StringInStr($aSource[$i], '\', 0, -1)), StringLen($sSourcePath)) If Not FileExists($sDestPath & $sNewFolder) Then If Not DirCreate($sDestPath & $sNewFolder) Then Return SetError(3, 0, 0) EndIf EndIf If $sFile = '' Then ContinueLoop $k = 0 While $bOverWrite = False And FileExists($sDestPath & $sNewFolder & $sFile) $k += 1 $sFile = $sPreFix & $k & "_" & StringMid($aSource[$i], StringInStr($aSource[$i], '\', 0, -1) + 1) WEnd $aReturn[$i] = $sDestPath & $sNewFolder & $sFile $sShowSource = StringRegExpReplace($aSource[$i], '(.{15})(.*)(.{35})', '$1' & '[...]' & '$3') GUICtrlSetData($aMFC[1], 'Source File ' & @CRLF & '"' & $sShowSource & '"' & @CRLF & 'Destination: "' & $sShowDest & '"') $ret = DllCall($DllKernel32, 'int', 'CopyFileExA', 'str', $aSource[$i], 'str', $aReturn[$i], 'ptr', $ptr, 'str', $sArray, 'int', 0, 'int', 0) If $ret[0] = 0 Then $aMFC[10] = True $aMFC[8] += FileGetSize($aSource[$i]) Next DllClose($DllKernel32) DllCallbackFree($callback) GUIDelete($aMFC[0]) DllClose($aMFC[11]) Opt('GUICloseOnESC', $oldGUICloseOnESC) Return $aReturn EndFunc ;==>_MultiFileCopy Func __Progress($FileSize, $BytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData) Local $aSplit = StringSplit(StringTrimRight($lpData, 1), ";") If $aSplit[11] = 'True' Then Return 1 Local $pos = GUIGetCursorInfo($aSplit[1]) If _IsPressed('1B', Int($aSplit[12])) Then Return 1 ;If _IsPressed('1B', $Button1) Then Return 1 If _IsPressed('01', Int($aSplit[12])) And ($pos[4] = Int($aSplit[7])) Then Return 1 Local $sPercent = Round($BytesTransferred / $FileSize * 100, 0), $iTime, $iTotalTime, $iTransferRate Local $sPercentAll = Round(($aSplit[9] + $BytesTransferred) / $aSplit[8] * 100, 0) $iTime = TimerDiff($aSplit[10]) $iTotalTime = Ceiling($iTime / 1000 / ($sPercentAll + 0.1) * 100) $iTransferRate = _StringAddThousandsSep(Int($aSplit[8] / $iTotalTime / 1000), '.', ',') GUICtrlSetData($Label5, $sPercent & ' %') GUICtrlSetData($Progress1, $sPercent) GUICtrlSetData($Label7, $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($Progress2, $sPercentAll) EndFunc ;==>__Progress Func __ProgressCreate(ByRef $aMFC) $aMFC[0] = $Form1 $aMFC[1] = $Label3;8 $aMFC[2] = $Label5;14 file % $aMFC[3] = $Label7;16 total % $aMFC[4] = $Progress1;7 $aMFC[5] = $Progress2;5 $aMFC[6] = $Button1;10 EndFunc ;==>__ProgressCreate Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0') Global $oFSO = ObjCreate('Scripting.FileSystemObject') Global $strFiles = '' Switch $sDelim Case '1' $sDelim = @CR Case '2' $sDelim = @LF Case '3' $sDelim = ';' Case '4' $sDelim = '|' Case Else $sDelim = @CRLF EndSwitch If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0 If $sExt = -1 Then $sExt = '*' If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1 _ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim) If $iRetType = 0 Then Local $aOut $aOut = StringSplit(StringTrimRight($strFiles, StringLen($sDelim)), $sDelim, 1) If $aOut[1] = '' Then ReDim $aOut[1] $aOut[0] = 0 EndIf Return $aOut Else Return StringTrimRight($strFiles, StringLen($sDelim)) EndIf EndFunc Func _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF) If Not IsDeclared("strFiles") Then Global $strFiles = '' If ($Dir = -1) Or ($Dir = 0) Then For $file In $Folder.Files If $Ext <> '*' Then If StringRight($file.Name, StringLen($Ext)) = $Ext Then $strSize += $file.size $strFiles &= $file.Path & $Delim EndIf Else $strSize += $file.size $strFiles &= $file.Path & $Delim EndIf Next EndIf For $Subfolder In $Folder.SubFolders If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim) Next EndFunc Link to comment Share on other sites More sharing options...
ZystemsK Posted April 14, 2009 Author Share Posted April 14, 2009 The text appears fine after each file is copied, though and also looks fine on the original MultiFileCopy script. Not sure what could have caused the problem. Link to comment Share on other sites More sharing options...
KaFu Posted April 14, 2009 Share Posted April 14, 2009 I think you'll have to rename the controls called by GuiCtrlSetData() in the __Progress() function. GUICtrlSetData($Label5, $sPercent & ' %') GUICtrlSetData($Progress1, $sPercent) GUICtrlSetData($Label7, $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($Progress2, $sPercentAll) with GUICtrlSetData($aMFC[2], $sPercent & ' %') GUICtrlSetData($aMFC[4], $sPercent) GUICtrlSetData($aMFC[3], $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($aMFC[5], $sPercentAll) Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ZystemsK Posted April 14, 2009 Author Share Posted April 14, 2009 I think you'll have to rename the controls called by GuiCtrlSetData() in the __Progress() function. GUICtrlSetData($Label5, $sPercent & ' %') GUICtrlSetData($Progress1, $sPercent) GUICtrlSetData($Label7, $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($Progress2, $sPercentAll) with GUICtrlSetData($aMFC[2], $sPercent & ' %') GUICtrlSetData($aMFC[4], $sPercent) GUICtrlSetData($aMFC[3], $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($aMFC[5], $sPercentAll) That's the way it was originally, I just changed it to use the direct label ones. I'll change it back. Link to comment Share on other sites More sharing options...
ZystemsK Posted April 14, 2009 Author Share Posted April 14, 2009 Changed it back to its original state and it's the same result (the Controls use $aSplit, not $aMFC) GUICtrlSetData($aSplit[3], $sPercent & ' %') GUICtrlSetData($aSplit[5], $sPercent) GUICtrlSetData($aSplit[4], $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($aSplit[6], $sPercentAll) Link to comment Share on other sites More sharing options...
KaFu Posted April 14, 2009 Share Posted April 14, 2009 (edited) Must have something to do with your usage of Tabs, just comment $Tab1 and you'll see what I mean. Edit: This works, but causes the GUI to flicker slightly expandcollapse popup#include<String.au3> #include<Misc.au3> #include<File.au3> #include<Array.au3> #include<GUIConstants.au3> #include<GUIConstantsEx.au3> #include<winapi.au3> #include<WindowsConstants.au3> Global $lpData_save #Region ### START Koda GUI section ### Form=C:\Koda\Forms\test.kxf If Not IsDeclared('WS_EX_COMPOSITED') Then Local Const $WS_EX_COMPOSITED = 0x02000000 $Form1 = GUICreate('MultiFileCopy', 633, 500, -1,-1,-1, -1) $Tab1 = GUICtrlCreateTab(32, 40, 537, 369) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Backup1") $Label1 = GUICtrlCreateLabel("Data Backup1", 41, 78, 202, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $Progress2 = GUICtrlCreateProgress(48, 340, 460, 20) $Progress1 = GUICtrlCreateProgress(48, 244, 460, 20) $Label3 = GUICtrlCreateLabel("", 48, 120, 340, 84) GUICtrlSetFont(-1, 10, 400, 0, 'Courier New') $Button1 = GUICtrlCreateButton("Cancel", 448, 368, 75, 25) GUICtrlSetFont(-1, 9, 400, 0, 'Arial') $Button2 = GUICtrlCreateButton("Backup", 88, 368, 75, 25) GUICtrlSetFont(-1, 9, 400, 0, 'Arial') $Input1 = GUICtrlCreateInput("", 400, 144, 121, 21) $Label8 = GUICtrlCreateLabel("Directory:", 400, 120, 92, 17) GUICtrlSetFont(-1, 10, 400, 0, 'Courier New') $Label4 = GUICtrlCreateLabel("File:", 48, 213, 60, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label5 = GUICtrlCreateLabel("0 %", 120, 213, 53, 25) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label6 = GUICtrlCreateLabel("Total:", 48, 304, 60, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $Label7 = GUICtrlCreateLabel("0 %", 120, 304, 390, 16) GUICtrlSetFont(-1, 11, 600, 0, 'Courier New') $TabSheet2 = GUICtrlCreateTabItem("Backup2") $Label2 = GUICtrlCreateLabel("Backup2", 41, 78, 145, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $Progress3 = GUICtrlCreateProgress(48, 244, 486, 17) $Progress4 = GUICtrlCreateProgress(48, 340, 486, 17) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("E&xit", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("&Help") $MenuItem4 = GUICtrlCreateMenuItem("&About", $MenuItem3) GUISetState() #EndRegion ### END Koda GUI section ### Global $strFiles = '', $strSize = 0, $strDatList[500], $strIdxList, $strFileList, $backupdir $source = @ScriptDir & "\test\" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $backupdir = $source & "SDBackup-" & @MON & "-" & @MDAY & "-" & @YEAR $strFileList = FileFindFirstFile($source & "*.dat") If Not @error Then $i = 1 While 1 $sFile = FileFindNextFile($strFileList) If @error Then $strDatList[0] = $i - 1 ExitLoop EndIf $strDatList[$i] = $source & $sFile $i += 1 WEnd EndIf FileClose($strFileList) Global $aReturn = _MultiFileCopy($strDatList, $backupdir, False) EndSwitch WEnd Func _MultiFileCopy($aSource, $sDestPath = '', $bOverWrite = True, $sPreFix = '') Global $aMFC[12] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, DllOpen('user32.dll')] Global $oldGUICloseOnESC = Opt('GUICloseOnESC', 0) Global $ret, $sShowSource, $sShowDest, $sSourcePath = '', $sNewFolder = '', $k Global $sArray __ProgressCreate($aMFC) If IsArray($aSource) Then If Not IsNumber($aSource[0]) Then Return SetError(1, 0, 0) For $i = 1 To $aSource[0] $aMFC[7] += FileGetSize($aSource[$i]) Next If $sDestPath = '' Then Return SetError(0, 0, 1) EndIf If StringRight($sDestPath, 1) <> '\' Then $sDestPath &= '\' If Not FileExists($sDestPath) Then If Not DirCreate($sDestPath) Then Return SetError(2, 0, 0) EndIf $sShowDest = StringRegExpReplace($sDestPath, '(.{15})(.*)(.{35})', '$1' & '[...]' & '$3') Global $aReturn = $aSource Global $callback = DllCallbackRegister('__Progress', 'int', 'uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;str') Global $ptr = DllCallbackGetPtr($callback) Global $DllKernel32 = DllOpen('kernel32.dll') $aMFC[9] = TimerInit() For $i = 1 To $aSource[0] $sArray = '' For $j = 0 To 11 $sArray &= $aMFC[$j] & ';' Next $sFile = StringMid($aSource[$i], StringInStr($aSource[$i], '\', 0, -1) + 1) If $sSourcePath <> '' Then $sNewFolder = StringTrimLeft(StringLeft($aSource[$i], StringInStr($aSource[$i], '\', 0, -1)), StringLen($sSourcePath)) If Not FileExists($sDestPath & $sNewFolder) Then If Not DirCreate($sDestPath & $sNewFolder) Then Return SetError(3, 0, 0) EndIf EndIf If $sFile = '' Then ContinueLoop $k = 0 While $bOverWrite = False And FileExists($sDestPath & $sNewFolder & $sFile) $k += 1 $sFile = $sPreFix & $k & "_" & StringMid($aSource[$i], StringInStr($aSource[$i], '\', 0, -1) + 1) WEnd $aReturn[$i] = $sDestPath & $sNewFolder & $sFile $sShowSource = StringRegExpReplace($aSource[$i], '(.{15})(.*)(.{35})', '$1' & '[...]' & '$3') GUICtrlSetData($aMFC[1], 'Source File ' & @CRLF & '"' & $sShowSource & '"' & @CRLF & 'Destination: "' & $sShowDest & '"') $ret = DllCall($DllKernel32, 'int', 'CopyFileExA', 'str', $aSource[$i], 'str', $aReturn[$i], 'ptr', $ptr, 'str', $sArray, 'int', 0, 'int', 0) If $ret[0] = 0 Then $aMFC[10] = True $aMFC[8] += FileGetSize($aSource[$i]) Next DllClose($DllKernel32) DllCallbackFree($callback) GUIDelete($aMFC[0]) DllClose($aMFC[11]) Opt('GUICloseOnESC', $oldGUICloseOnESC) Return $aReturn EndFunc ;==>_MultiFileCopy Func __Progress($FileSize, $BytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData) if $lpData <> $lpData_save then Local $aSplit = StringSplit(StringTrimRight($lpData, 1), ";") If $aSplit[11] = 'True' Then Return 1 Local $pos = GUIGetCursorInfo($aSplit[1]) If _IsPressed('1B', Int($aSplit[12])) Then Return 1 If _IsPressed('01', Int($aSplit[12])) And ($pos[4] = Int($aSplit[7])) Then Return 1 Local $sPercent = Round($BytesTransferred / $FileSize * 100, 0), $iTime, $iTotalTime, $iTransferRate Local $sPercentAll = Round(($aSplit[9] + $BytesTransferred) / $aSplit[8] * 100, 0) $iTime = TimerDiff($aSplit[10]) $iTotalTime = Ceiling($iTime / 1000 / ($sPercentAll + 0.1) * 100) $iTransferRate = _StringAddThousandsSep(Int($aSplit[8] / $iTotalTime / 1000), '.', ',') GUISetState(@SW_LOCK) GUICtrlSetData($aSplit[3], $sPercent & ' %') GUICtrlSetData($aSplit[5], $sPercent) GUICtrlSetData($aSplit[4], $sPercentAll & ' % Time: ' & Int($iTime / 1000) & '/' & $iTotalTime & ' s (' & $iTransferRate & ' KB/s)') GUICtrlSetData($aSplit[6], $sPercentAll) ;GuiCtrlCreateTabItem("") GUISetState(@SW_UNLOCK) ;_WinAPI_RedrawWindow(ControlGetHandle($Form1,"",$TabSheet1)) endif EndFunc ;==>__Progress Func __ProgressCreate(ByRef $aMFC) $aMFC[0] = $Form1 $aMFC[1] = $Label3;8 $aMFC[2] = $Label5;14 file % $aMFC[3] = $Label7;16 total % $aMFC[4] = $Progress1;7 $aMFC[5] = $Progress2;5 $aMFC[6] = $Button1;10 EndFunc ;==>__ProgressCreate Func _GetFilesFolder_Rekursiv($sPath, $sExt = '*', $iDir = -1, $iRetType = 0, $sDelim = '0') Global $oFSO = ObjCreate('Scripting.FileSystemObject') Global $strFiles = '' Switch $sDelim Case '1' $sDelim = @CR Case '2' $sDelim = @LF Case '3' $sDelim = ';' Case '4' $sDelim = '|' Case Else $sDelim = @CRLF EndSwitch If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0 If $sExt = -1 Then $sExt = '*' If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1 _ShowSubFolders($oFSO.GetFolder($sPath), $sExt, $iDir, $sDelim) If $iRetType = 0 Then Local $aOut $aOut = StringSplit(StringTrimRight($strFiles, StringLen($sDelim)), $sDelim, 1) If $aOut[1] = '' Then ReDim $aOut[1] $aOut[0] = 0 EndIf Return $aOut Else Return StringTrimRight($strFiles, StringLen($sDelim)) EndIf EndFunc ;==>_GetFilesFolder_Rekursiv Func _ShowSubFolders($Folder, $Ext = '*', $Dir = -1, $Delim = @CRLF) If Not IsDeclared("strFiles") Then Global $strFiles = '' If ($Dir = -1) Or ($Dir = 0) Then For $file In $Folder.Files If $Ext <> '*' Then If StringRight($file.Name, StringLen($Ext)) = $Ext Then $strSize += $file.size $strFiles &= $file.Path & $Delim EndIf Else $strSize += $file.size $strFiles &= $file.Path & $Delim EndIf Next EndIf For $Subfolder In $Folder.SubFolders If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim) Next EndFunc ;==>_ShowSubFolders Edited April 14, 2009 by KaFu  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ZystemsK Posted April 14, 2009 Author Share Posted April 14, 2009 Yeah, removing the tab worked and using the lock/unlock seems to lock up my PC for a few while it's running. I'm only using this method for copying files because it's the only one I could find that I somewhat understand. I'll take a look at your SMF script and see if I can find anything useful in it, though I don't think you use progress bars. Link to comment Share on other sites More sharing options...
ZystemsK Posted April 14, 2009 Author Share Posted April 14, 2009 (edited) After a bit of searching, I found another method and combined the two. Here's what I came up with, minus the GUI part. It's still ugly and redundant in many places, but it works and I'll clean it up later. Thanks. expandcollapse popupFunc ProgressCopy($current, $destination, $attrib = "-R", $overwrite = 1 ,$Run1 = 0 ) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 Then ; Create dll hooks for Progress Update If Not IsDeclared("callback") Then Local $callback = DllCallbackRegister('__Progress', 'int', 'uint64;uint64;uint64;uint64;dword;dword;ptr;ptr;str') If Not IsDeclared("ptr") Then Local $ptr = DllCallbackGetPtr($callback) Global $oldGUICloseOnESC = Opt('GUICloseOnESC', 0), $masks[2] = ["*.dat", "*.idx"], $Size, $Qty Global $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $LocalPercent If not FileExists ($Destination) then DirCreate ($Destination); This is why it was failing, the dir did not exist $source = $current If StringRight($destination, 1) <> '\' Then $destination = $destination & '\' $progressbar1 = $Progress2 $progressbar2 = $Progress1 $Progress0Text = $TotalProgress $Progress2Text = $SourceFile $Run1 = 1 EndIf $Overall = _DirGetSizeEx($current, $masks[0]) $OverallQty = $Overall[0] $Overall = _DirGetSizeEx($current, $masks[1]) $OverallQty += $Overall[0] $Overall = $OverallQty For $i=0 to 1 $Size = _DirGetSizeEx($current, $masks[$i]) $Qty = $Size[0] Local $search = FileFindFirstFile($current & $masks[$i]) While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & $file), "D") And ($file <> "." Or $file <> "..") Then $Qty -= FileGetSize($current & $file) $LocalPercent = 100 - (($Qty / $Size[0]) * 100) $OverallQty -= FileGetSize($current & $file) $overallpercent = 100 - (($OverallQty / $Overall) * 100) GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed") GUICtrlSetData($progressbar1, $overallpercent) GUICtrlSetData($progressbar2, $LocalPercent) GUICtrlSetData($Progress2Text, "Source: " & $file) GUICtrlSetData($DestFile, "Destination: " & $Destination & $file) If _IsPressed('1B', $Button1) Then ExitLoop $ret = DllCall('kernel32.dll', 'int', 'CopyFileExA', 'str', $current & $file, 'str', $destination & $file, 'ptr', $ptr, 'str', '', 'int', 0, 'int', 0) FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, $attrib) EndIf WEnd FileClose($search) Next ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $overallpercent = 100 Then GUICtrlSetData($Progress0Text, "Total Progress 100% completed") GUICtrlSetData($progressbar1, 100) GUICtrlSetData($progressbar2, 100) GUICtrlSetData($Progress2Text, "Done!") Opt('GUICloseOnESC', $oldGUICloseOnESC) $Run1 = 0 EndIf EndFunc ;==>ProgressCopy Func _DirGetSizeEx($sPath, $wildcard) Local $sSearch, $aResult[3] If StringRight($sPath, 1) <> "\" Then $sPath &= "\"; Ensure $sPath has a trailing slash $sSearch = FileFindFirstFile($sPath & $wildcard) While 1 $sNext = FileFindNextFile($sSearch); check if next file can be found, otherwise exit loop If @error Then ExitLoop If Not StringInStr(FileGetAttrib($sPath & $sNext), "D") Then $aResult[1] += 1 $aResult[0] += FileGetSize($sPath & $sNext) EndIf WEnd FileClose($sSearch) Return $aResult EndFunc ;==>_DirGetSizeEx Func __Progress($FileSize, $BytesTransferred, $StreamSize, $StreamBytesTransferred, $dwStreamNumber, $dwCallbackReason, $hSourceFile, $hDestinationFile, $lpData) GUICTRLSetData($Progress1, (Round($BytesTransferred / $FileSize * 100, 0))) EndFunc Edited April 14, 2009 by ZystemsK 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