gahhon Posted February 1, 2019 Author Posted February 1, 2019 (edited) 52 minutes ago, pixelsearch said: Hi all Just to share with you the simplest way to copy a folder into another one, displaying Windows native progress bar at same time : #include <AutoItConstants.au3> #include <WinAPIShellEx.au3> SplashTextOn("", "Installation in progress...", _ 250, 50, -1, 220, $DLG_NOTITLE + $DLG_TEXTVCENTER) _WinAPI_ShellFileOperation("C:\From folder", "C:\To Folder", _ $FO_COPY, $FOF_SIMPLEPROGRESS) SplashOff() Thanks for the helps buddy. This can show the splashtext and knowing the progress of copying. But do this Copy method is auto overwrite if the folders/files are already existed? Because the DirCopy have to parameter to control whether is just pure-copy, overwrite, etc. Somehow, I have create the custom SplashText Screen with Metro UDF. Here is the functions I created expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _Metro_SplashTextScreen ; Description ...: Creates a metro style SplashText Screen ; Syntax ........: _Metro_SplashTextScreen($Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = ""]]]) ; Parameters ....: $Flag - 1 = Create GUI, 0 = Delete GUI, Others = Return ERROR ; $Title - [optional] Title of the MsgBox. ; $Text - [optional] Text of the MsgBox. ; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. ; $FontSize - [optional] Fontsize. Default is 11. ; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". ; ; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. ; =============================================================================================================================== Func _Metro_SplashTextScreen($Flag, $Title = "", $Text = "", $mWidth = 600, $Fontsize = 11, $ParentGUI = "") Local $msgbDPI = _HighDPICheck() Local $SplashScreen_Form If $Flag = 1 Then If $HIGHDPI_SUPPORT Then $mWidth = Round($mWidth * $gDPI) Else $Fontsize = ($Fontsize / $Font_DPI_Ratio) EndIf Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) $SplashScreen_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) GUICtrlSetColor(-1, $FontThemeColor) _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) $iLableID = GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) GUICtrlSetBkColor(-1, $GUIThemeColor) GUICtrlSetColor(-1, $FontThemeColor) GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) GUISetState(@SW_SHOW) Sleep(500) Return 1 ElseIf $Flag = 0 Then GUIDelete($SplashScreen_Form) Return 1 Else Return SetError(0, "", "Error: Invalid flag value") EndIf EndFunc ;==>_Metro_SplashTextScreen Then I apply this function and @pixelsearch method to my application If FileExists($DIR_WA_FOLDER) = 0 Then Local $Decisions = _Metro_MsgBox(4, "", "Do you want to install Extension?") If $Decisions = "Yes" Then _Metro_SplashTextScreen(1, "", "Copying...") ;DirCopy($CUR_WA_FOLDER, $DIR_WA_FOLDER, 1) _WinAPI_ShellFileOperation($CUR_WA_FOLDER, $DIR_WA_FOLDER, $FO_COPY, $FOF_SIMPLEPROGRESS) _Metro_SplashTextScreen(0) _Metro_MsgBox(0, "", "Extension is installed") _FileWriteLog($LOG_INSTALLATION, "Debug: Application is installed.") Else _Close_Application() EndIf EndIf This would do the trick actually, but is that possible to make text of Copying... update dynamically second by second until the copy is finish? Like this example: Look at SMOOTH #include <AutoItConstants.au3> SplashTextOn("Title", "Message goes here.", -1, -1, -1, -1, $DLG_TEXTLEFT, "", 24) Sleep(3000) SplashOff() ; ; FLICKER Local $sMessage = "" SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "") For $i = 1 To 20 $sMessage = $sMessage & $i & @CRLF SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "") Sleep(100) Next ; ; SMOOTH $sMessage = "" SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "") For $i = 1 To 20 $sMessage = $sMessage & $i & @CRLF ControlSetText("TitleFoo", "", "Static1", $sMessage) Sleep(100) Next I have try create this function to do trick, but it keep stuck that without updating. Global $iLableID Func _Metro_SetSplashText($newMessage) GUICtrlSetData($iLableID, $newMessage) ;$iLabelID is assigned at _Metro_SplashTextScreen() EndFunc ;==>_Metro_SetSplashText Thanks. Edited February 1, 2019 by gahhon To improve what I've tried.
pixelsearch Posted February 1, 2019 Posted February 1, 2019 (edited) 16 hours ago, gahhon said: But do this Copy method is auto overwrite if the folders/files are already existed? By default safety is On If files/dirs exist, you will be asked to overwrite or not, skip all etc... just like usual copies in windows Explorer Just have a look at _WinAPI_ShellFileOperation() in AutoIt help file, you'll see dozens of flags you can use, depending on your needs. Also you can analyze what happens if copy fails (@extended will then contain the reason why) For example, to overwrite without being warned, you add the $FOF_NOCONFIRMATION flag. I just did it now and : * Without the flag, I was asked if I wanted to overwrite. * With the flag, I was asked nothing, all was overwritten silently with this simple line ; _WinAPI_ShellFileOperation("C:\Prog\*.*", "C:\Prog2", _ $FO_COPY, BitOr($FOF_SIMPLEPROGRESS, $FOF_NOCONFIRMATION)) I notice there are other useful flags like $FOF_NOCONFIRMMKDIR etc... This command is also useful if you want to move, rename or delete, all of this with a progress bar, it appears to be very complete. Good luck, whatever the method you'll choose Edited February 2, 2019 by pixelsearch changed C:\Prog => C:\Prog\*.* "I think you are searching a bug where there is no bug... don't listen to bad advice."
gahhon Posted February 2, 2019 Author Posted February 2, 2019 $FOF_SIMPLEPROGRESS 8 hours ago, pixelsearch said: By default safety is On If files/dirs exist, you will be asked to overwrite or not, skip all etc... just like usual copies in windows Explorer Just have a look at _WinAPI_ShellFileOperation() in AutoIt help file, you'll see dozens of flags you can use, depending on your needs. Also you can analyze what happens if copy fails (@extended will then contain the reason why) For example, to overwrite without being warned, you add the $FOF_NOCONFIRMATION flag. I just did it now and : * Without the flag, I was asked if I wanted to overwrite. * With the flag, I was asked nothing, all was overwritten silently with this simple line ; _WinAPI_ShellFileOperation("C:\Prog", "C:\Prog2", _ $FO_COPY, BitOr($FOF_SIMPLEPROGRESS, $FOF_NOCONFIRMATION)) I notice there are other useful flags like $FOF_NOCONFIRMMKDIR etc... This command is also useful if you want to move, rename or delete, all of this with a progress bar, it appears to be very complete. Good luck, whatever the method you'll choose You just use is $FOF_SIMPLEPROGRESS instead of $FOF_NOCONFIRMMKDIR tho. I just tried with $FOF_NO_UI, it still copying without asked And how can I know what's is their pattern each of the $iFlags value?
caramen Posted February 2, 2019 Posted February 2, 2019 (edited) Well i finish. I did it. Here is the new UDF, You just have to edit 2 $var it's simple. expandcollapse popupFunc _CopyDirWithProgress($sOriginalDir, $sDestDir) ;$sOriginalDir and $sDestDir are quite selfexplanatory... ;This func returns: ; -1 in case of critical error, bad original or destination dir ; 0 if everything went all right ; >0 is the number of file not copied and it makes a log file ; if in the log appear as error message '0 file copied' it is a bug of some windows' copy command that does not redirect output... If StringRight($sOriginalDir, 1) <> '\' Then $sOriginalDir = $sOriginalDir & '\' If StringRight($sDestDir, 1) <> '\' Then $sDestDir = $sDestDir & '\' If $sOriginalDir = $sDestDir Then Return -1 ;ProgressOn('Copie en cours...', 'Liste les fichiers...' & @LF & @LF, '', -1, -1, 18) ;$ProgressOn ;$ProgressOnLabel1 Local $aFileList = _FileSearch($sOriginalDir) If $aFileList[0] = 0 Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(1) Return -1 EndIf If FileExists($sDestDir) Then If Not StringInStr(FileGetAttrib($sDestDir), 'd') Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(2) Return -1 EndIf Else DirCreate($sDestDir) If Not FileExists($sDestDir) Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(2) Return -1 EndIf EndIf Local $iDirSize, $iCopiedSize = 0, $fProgress = 0 Local $c, $FileName, $iOutPut = 0, $sLost = '', $sError Local $Sl = StringLen($sOriginalDir) _Quick_Sort($aFileList, 1, $aFileList[0]) $iDirSize = Int(DirGetSize($sOriginalDir) / 1024) ;ProgressSet(Int($fProgress * 100), $aFileList[$c], 'Copie des fichiers:') _Metro_SetProgress($ProgressOn , Int ($fProgress * 100) ) For $c = 1 To $aFileList[0] $FileName = StringTrimLeft($aFileList[$c], $Sl) _Metro_SetProgress($ProgressOn , Int ($fProgress * 100) ) GUICtrlSetData ( $ProgressOnLabel1 , "Copying: File "&$c&" / "&$aFileList[0]) If StringInStr(FileGetAttrib($aFileList[$c]), 'd') Then DirCreate($sDestDir & $FileName) Else If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then;Tries a second time If RunWait(@ComSpec & ' /c copy /y "' & $aFileList[$c] & '" "' & $sDestDir & $FileName & '">' & @TempDir & '\o.tmp', '', @SW_HIDE)=1 Then;and a third time, but this time it takes the error message $sError = FileReadLine(@TempDir & '\o.tmp',1) $iOutPut = $iOutPut + 1 $sLost = $sLost & $aFileList[$c] & ' ' & $sError & @CRLF EndIf FileDelete(@TempDir & '\o.tmp') EndIf EndIf FileSetAttrib($sDestDir & $FileName, "+A-RSH");<- Comment this line if you do not want attribs reset. $iCopiedSize = $iCopiedSize + Int(FileGetSize($aFileList[$c]) / 1024) $fProgress = $iCopiedSize / $iDirSize EndIf Next ;ProgressOff() _Metro_SetProgress($Progress , 1 ) If $sLost <> '' Then;tries to write the log somewhere. If FileWrite($sDestDir & 'notcopied.txt',$sLost) = 0 Then If FileWrite($sOriginalDir & 'notcopied.txt',$sLost) = 0 Then FileWrite(@WorkingDir & '\notcopied.txt',$sLost) EndIf EndIf EndIf Return $iOutPut EndFunc ;==>_CopyDirWithProgress Func _FileSearch($sIstr, $bSF = 1) ; $bSF = 1 means looking in subfolders ; $sSF = 0 means looking only in the current folder. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] ;, $sIstr, $bSF $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) If $sCS <> - 1 Then Do $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop $sOutPut = $sOutPut & $sCP & $sCF & @LF Until 0 EndIf ;And after, if needed, in the rest of the folders. If $bSF = 1 Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) If $iH <> - 1 Then Do $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future searches $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. If $iH2 <> - 1 Then Do $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. Until 0 EndIf EndIf Until 0 EndIf $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code Dim $Low, $High Dim $Temp, $List_Separator $Low = $First $High = $Last $List_Separator = StringLen($SortArray[ ($First + $Last) / 2]) Do While (StringLen($SortArray[$Low]) < $List_Separator) $Low = $Low + 1 WEnd While (StringLen($SortArray[$High]) > $List_Separator) $High = $High - 1 WEnd If ($Low <= $High) Then $Temp = $SortArray[$Low] $SortArray[$Low] = $SortArray[$High] $SortArray[$High] = $Temp $Low = $Low + 1 $High = $High - 1 EndIf Until $Low > $High If ($First < $High) Then _Quick_Sort($SortArray, $First, $High) If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last) EndFunc ;==>_Quick_Sort Step 1: You copy past this into your script. Step 2: You make a MetroProgress named $ProgressOn Step 2.2 : Then You set it at 100% with _Metro_SetProgress($ProgressOn , 100 ) Step 3: You make a label named $ProgressOnLabel1 If you use the _CopyDirWithProgress($sOriginalDir, $sDestDir) it will update the progress bar named : $ProgressOn &the label named: $ProgressOnLabel1 Without file names. Only displaying : "Copying : */x" You can make them into custome external gui metro windows Pheww! You are pretty lucky i was working on somthing similar so i ll use it ============================================== If you want external windows : Name your Gui $hGui Or rename $hGUI this udf: expandcollapse popupFunc _CopyDirWithProgress($sOriginalDir, $sDestDir) ;$sOriginalDir and $sDestDir are quite selfexplanatory... ;This func returns: ; -1 in case of critical error, bad original or destination dir ; 0 if everything went all right ; >0 is the number of file not copied and it makes a log file ; if in the log appear as error message '0 file copied' it is a bug of some windows' copy command that does not redirect output... $hGUI2 = _Metro_CreateGUI ( "ITMigra2", 200 , 200 , -1, -1, False , $hGUI ) $Control_Buttons2 = _Metro_AddControlButtons(True, False, True, False, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True $ProgressOn = _Metro_CreateProgress (25, 55 , 150, 30) $ProgressOnLabel1 = GUICtrlCreateLabel(" copy ? ",40, 95 , 120, 40) GUICtrlSetColor($ProgressOnLabel1, 0xFB1924) _Metro_SetProgress($ProgressOn , 100 ) GUISetState( @SW_HIDE , $hGUI2 ) If StringRight($sOriginalDir, 1) <> '\' Then $sOriginalDir = $sOriginalDir & '\' If StringRight($sDestDir, 1) <> '\' Then $sDestDir = $sDestDir & '\' If $sOriginalDir = $sDestDir Then Return -1 ;ProgressOn('Copie en cours...', 'Liste les fichiers...' & @LF & @LF, '', -1, -1, 18) ;$ProgressOn ;$ProgressOnLabel1 Local $aFileList = _FileSearch($sOriginalDir) If $aFileList[0] = 0 Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(1) Return -1 EndIf If FileExists($sDestDir) Then If Not StringInStr(FileGetAttrib($sDestDir), 'd') Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(2) Return -1 EndIf Else DirCreate($sDestDir) If Not FileExists($sDestDir) Then ;ProgressOff() _Metro_SetProgress($Progress , 1 ) SetError(2) Return -1 EndIf EndIf Local $iDirSize, $iCopiedSize = 0, $fProgress = 0 Local $c, $FileName, $iOutPut = 0, $sLost = '', $sError Local $Sl = StringLen($sOriginalDir) _Quick_Sort($aFileList, 1, $aFileList[0]) $iDirSize = Int(DirGetSize($sOriginalDir) / 1024) ProgressSet(Int($fProgress * 100), $aFileList[$c], 'Copie des fichiers:') For $c = 1 To $aFileList[0] $FileName = StringTrimLeft($aFileList[$c], $Sl) GUISetState( @SW_SHOW , $hGUI2 ) _Metro_SetProgress($ProgressOn , Int ($fProgress * 100) ) GUICtrlSetData ( $ProgressOnLabel1 , "Copying: File "&$c&" / "&$aFileList[0]) If StringInStr(FileGetAttrib($aFileList[$c]), 'd') Then DirCreate($sDestDir & $FileName) Else If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then If Not FileCopy($aFileList[$c], $sDestDir & $FileName, 1) Then;Tries a second time If RunWait(@ComSpec & ' /c copy /y "' & $aFileList[$c] & '" "' & $sDestDir & $FileName & '">' & @TempDir & '\o.tmp', '', @SW_HIDE)=1 Then;and a third time, but this time it takes the error message $sError = FileReadLine(@TempDir & '\o.tmp',1) $iOutPut = $iOutPut + 1 $sLost = $sLost & $aFileList[$c] & ' ' & $sError & @CRLF EndIf FileDelete(@TempDir & '\o.tmp') EndIf EndIf FileSetAttrib($sDestDir & $FileName, "+A-RSH");<- Comment this line if you do not want attribs reset. $iCopiedSize = $iCopiedSize + Int(FileGetSize($aFileList[$c]) / 1024) $fProgress = $iCopiedSize / $iDirSize EndIf Next ;ProgressOff() _Metro_SetProgress($Progress , 1 ) If $sLost <> '' Then;tries to write the log somewhere. If FileWrite($sDestDir & 'notcopied.txt',$sLost) = 0 Then If FileWrite($sOriginalDir & 'notcopied.txt',$sLost) = 0 Then FileWrite(@WorkingDir & '\notcopied.txt',$sLost) EndIf EndIf EndIf _Metro_GUIDelete ( $hGui2 ) Return $iOutPut EndFunc ;==>_CopyDirWithProgress Func _FileSearch($sIstr, $bSF = 1) ; $bSF = 1 means looking in subfolders ; $sSF = 0 means looking only in the current folder. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] ;, $sIstr, $bSF $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) If $sCS <> - 1 Then Do $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop $sOutPut = $sOutPut & $sCP & $sCF & @LF Until 0 EndIf ;And after, if needed, in the rest of the folders. If $bSF = 1 Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) If $iH <> - 1 Then Do $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future searches $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. If $iH2 <> - 1 Then Do $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. Until 0 EndIf EndIf Until 0 EndIf $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code Dim $Low, $High Dim $Temp, $List_Separator $Low = $First $High = $Last $List_Separator = StringLen($SortArray[ ($First + $Last) / 2]) Do While (StringLen($SortArray[$Low]) < $List_Separator) $Low = $Low + 1 WEnd While (StringLen($SortArray[$High]) > $List_Separator) $High = $High - 1 WEnd If ($Low <= $High) Then $Temp = $SortArray[$Low] $SortArray[$Low] = $SortArray[$High] $SortArray[$High] = $Temp $Low = $Low + 1 $High = $High - 1 EndIf Until $Low > $High If ($First < $High) Then _Quick_Sort($SortArray, $First, $High) If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last) EndFunc ;==>_Quick_Sort Personaly i use the external windows it's pretty cool. Edited February 2, 2019 by caramen gahhon 1 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
pixelsearch Posted February 2, 2019 Posted February 2, 2019 (edited) @gahhon : as your concern is to control what may happen if the folders/files already exist, then the only 2 flags that should be important to you are $FOF_NOCONFIRMMKDIR and $FOF_NOCONFIRMATION What follows works fine for me, so I suggest you to test it just like I just did : * Create a folder named C:\Test on your drive, with a couple of subfolders in it, then add a few files in C:\Test and its subfolders. Change the properties of 2-3 files to "read-only" * Launch this basic script #1 : _WinAPI_ShellFileOperation("C:\Test\*.*", "C:\Test2", _ $FO_COPY, $FOF_SIMPLEPROGRESS) * A window will appear, telling you that "folder Test2 doesn't exist, do you want to create it ?" Answer No and the script ends. Now we know that script #1 warns us when a folder doesn't exist. Let's find a way for not being warned in this case : * Add the flag $FOF_NOCONFIRMMKDIR ("don't confirm the creation of directories/folders") and run this modified script #2 : _WinAPI_ShellFileOperation("C:\Test\*.*", "C:\Test2", _ $FO_COPY, BitOr($FOF_SIMPLEPROGRESS, $FOF_NOCONFIRMMKDIR)) * No warning appears, everything is created/copied, which means that $FOF_NOCONFIRMMKDIR did the job concerning the warning of folders creation. You have now a new folder C:\Test2 on your drive, fully filled. Keep it. * Now let's run again script #2 to see what happens when all folders/files already exist. A warning appears that "a file (book2.xls in my case) already exists. Do you want to overwrite it ?" And the 4 usual buttons are here : "Yes", "All", "No", "Cancel" Answer Cancel and the script ends. Now we know that script #2 warns us when a file already exists. Let's find a way for not being warned in this case : * Add the flag $FOF_NOCONFIRMATION and run this modified script #3 : _WinAPI_ShellFileOperation("C:\Test\*.*", "C:\Test2", _ $FO_COPY, BitOr($FOF_SIMPLEPROGRESS, $FOF_NOCONFIRMMKDIR, $FOF_NOCONFIRMATION)) * No warning appears, everything is overwritten, which means that $FOF_NOCONFIRMATION did the job concerning the warning of "files already existing" That's it, with these 2 flags you can control all possibilities. I notice that it's important to indicate C:\Test\*.* (and not C:\Test) if you don't want the whole directory C:\Test to be copied as a subfolder inside C:\Temp2 The exact meaning of the other flags ? The answer should probably be found at MSDN, but if you're fully satisfied with the precedent tests, I suggest you don't waste your time with them. As I'm curious, I just tested $FOF_NORECURSION, it doesn't copy what's inside of the subfolders (though it creates the empty subfolders) Have a great week-end Edited February 2, 2019 by pixelsearch gahhon 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
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