Yashied Posted November 5, 2010 Share Posted November 5, 2010 (edited) LAST VERSION - 1.418-May-12This small library allows simple and reliable way to copy or move files and directories without suspending your script. Moreover, you can get the current state (number of copied bytes, system error code, and other status information) while copying. Also supported copying or moving a multiple files and directories at once (up to 256). Working with this UDF is similar with the InetGet() function. For more information, see description for each function within the library.Available functions_Copy_Abort_Copy_CallbackDlg_Copy_CloseDll_Copy_CopyDir_Copy_CopyFile_Copy_GetAction_Copy_GetState_Copy_MoveDir_Copy_MoveFile_Copy_OpenDll_Copy_PauseCopy UDF Library v1.4 (x86 and x64)Previous downloads: 1162Copy.zipExamplesCopying a single file#Include <Misc.au3> #Include "Copy.au3" Opt('TrayAutoPause', 0) $Source = 'C:\Test.tmp' $Destination = 'C:\Test (2).tmp' _Copy_OpenDll() _Copy_CopyFile($Source, $Destination) Do Sleep(250) $State = _Copy_GetState() ConsoleWrite(StringFormat('%.2f%', $State[1] / $State[2] * 100) & @CR) If _IsPressed('1B') Then _Copy_Abort() EndIf Until Not $State[0] ConsoleWrite('Return code: ' & $State[5] & @CR) _Copy_CloseDll()Copying a multiple files at once#Include <Misc.au3> #Include "Copy.au3" Opt('TrayAutoPause', 0) $Source1 = 'C:\Test1.tmp' $Destination1 = 'C:\Test1 (2).tmp' $Source2 = 'C:\Test2.tmp' $Destination2 = 'C:\Test2 (2).tmp' _Copy_OpenDll() _Copy_CopyFile($Source1, $Destination1, 0, 0) _Copy_CopyFile($Source2, $Destination2, 0, 1) Do Sleep(250) $State1 = _Copy_GetState(0) $State2 = _Copy_GetState(1) ConsoleWrite(StringFormat('%.2f% %.2f%', $State1[1] / $State1[2] * 100, $State2[1] / $State2[2] * 100) & @CR) If _IsPressed('1B') Then _Copy_Abort(0) _Copy_Abort(1) EndIf Until (Not $State1[0]) And (Not $State2[0]) ConsoleWrite('Return code #1: ' & $State1[5] & @CR) ConsoleWrite('Return code #2: ' & $State2[5] & @CR) _Copy_CloseDll()GUI, files copyingexpandcollapse popup#Include <EditConstants.au3> #Include <GUIConstantsEx.au3> #Include "Copy.au3" Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) Global $hForm, $Input1, $Input2, $Button1, $Button2, $Button3, $Button4, $Data, $Msg, $Path, $Progress, $State, $Copy = False, $Pause = False Global $Source = '', $Destination = '' If Not _Copy_OpenDll() Then MsgBox(16, '', 'DLL not found.') Exit EndIf $hForm = GUICreate('MyGUI', 360, 163) GUICtrlCreateLabel('Source:', 14, 23, 58, 14) $Input1 = GUICtrlCreateInput('', 74, 20, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE)) GUICtrlSetState(-1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton('...', 326, 19, 21, 21) GUICtrlCreateLabel('Destination:', 14, 55, 58, 14) $Input2 = GUICtrlCreateInput('', 74, 52, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE)) GUICtrlSetState(-1, $GUI_DISABLE) $Button2 = GUICtrlCreateButton('...', 326, 51, 21, 21) $Progress = GUICtrlCreateProgress(14, 94, 332, 16) $Button3 = GUICtrlCreateButton('Copy', 135, 126, 80, 21) $Button4 = GUICtrlCreateButton(';', 326, 126, 21, 21) GUICtrlSetFont(-1, 10, 400, 0, 'Webdings') GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 If $Copy Then $State = _Copy_GetState() If $State[0] Then $Data = Round($State[1] / $State[2] * 100) If GUICtrlRead($Progress) <> $Data Then GUICtrlSetData($Progress, $Data) EndIf Else Switch $State[5] Case 0 GUICtrlSetData($Progress, 100) MsgBox(64, '', 'File was successfully copied.', 0, $hForm) Case 1235 ; ERROR_REQUEST_ABORTED MsgBox(16, '', 'File copying was aborted.', 0, $hForm) Case Else MsgBox(16, '', 'File was not copied.' & @CR & @CR & $State[5], 0, $hForm) EndSwitch GUICtrlSetData($Progress, 0) GUICtrlSetState($Button1, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_ENABLE) GUICtrlSetState($Button4, $GUI_DISABLE) GUICtrlSetData($Button3, 'Copy') GUICtrlSetData($Button4, ';') $Copy = 0 EndIf EndIf $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 $Path = FileOpenDialog('Select Source File', StringRegExpReplace($Source, '\\[^\\]*\Z', ''), 'All Files (*.*)', 3, StringRegExpReplace($Source, '^.*\\', ''), $hForm) If $Path Then GUICtrlSetData($Input1, $Path) $Source = $Path EndIf Case $Button2 $Path = FileOpenDialog('Select Destination File', StringRegExpReplace($Destination, '\\[^\\]*\Z', ''), 'All Files (*.*)', 2, StringRegExpReplace($Source, '^.*\\', ''), $hForm) If $Path Then GUICtrlSetData($Input2, $Path) $Destination = $Path EndIf Case $Button3 If $Copy Then _Copy_Abort() Else If (Not $Source) Or (Not $Destination) Then MsgBox(16, '', 'The source and destination file names must be specified.', 0, $hForm) ContinueLoop EndIf If FileExists($Destination) Then If MsgBox(51, '', $Destination & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $hForm) <> 6 Then ContinueLoop EndIf EndIf GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_DISABLE) GUICtrlSetState($Button4, $GUI_ENABLE) GUICtrlSetData($Button3, 'Abort') _Copy_CopyFile($Source, $Destination) $Copy = 1 EndIf Case $Button4 $Pause = Not $Pause If $Pause Then GUICtrlSetData($Button4, '4') Else GUICtrlSetData($Button4, ';') EndIf _Copy_Pause($Pause) EndSwitch WEndGUI, directories copyingexpandcollapse popup#Include <EditConstants.au3> #Include <GUIConstantsEx.au3> #Include "Copy.au3" Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) Global $hForm, $Input1, $Input2, $Button1, $Button2, $Button3, $Button4, $Label, $Data, $Msg, $Path, $Progress, $State, $Copy = False, $Pause = False Global $Source = '', $Destination = '' If Not _Copy_OpenDll() Then MsgBox(16, '', 'DLL not found.') Exit EndIf $hForm = GUICreate('MyGUI', 360, 175) GUICtrlCreateLabel('Source:', 14, 23, 58, 14) $Input1 = GUICtrlCreateInput('', 74, 20, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE)) GUICtrlSetState(-1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton('...', 326, 19, 21, 21) GUICtrlCreateLabel('Destination:', 14, 55, 58, 14) $Input2 = GUICtrlCreateInput('', 74, 52, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE)) GUICtrlSetState(-1, $GUI_DISABLE) $Button2 = GUICtrlCreateButton('...', 326, 51, 21, 21) $Label = GUICtrlCreateLabel('',14, 91, 332, 14) $Progress = GUICtrlCreateProgress(14, 106, 332, 16) $Button3 = GUICtrlCreateButton('Copy', 135, 138, 80, 21) $Button4 = GUICtrlCreateButton(';', 326, 138, 21, 21) GUICtrlSetFont(-1, 10, 400, 0, 'Webdings') GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 If $Copy Then $State = _Copy_GetState() If $State[0] Then If $State[0] = -1 Then ; Preparing Else $Data = Round($State[1] / $State[2] * 100) If GUICtrlRead($Progress) <> $Data Then GUICtrlSetData($Progress, $Data) EndIf $Data = StringRegExpReplace($State[6], '^.*\\', '') If GUICtrlRead($Label) <> $Data Then GUICtrlSetData($Label, $Data) EndIf EndIf Else Switch $State[5] Case 0 GUICtrlSetData($Progress, 100) MsgBox(64, '', 'Folder was successfully copied.', 0, $hForm) Case 1235 ; ERROR_REQUEST_ABORTED MsgBox(16, '', 'Folder copying was aborted.', 0, $hForm) Case Else MsgBox(16, '', 'Folder was not copied.' & @CR & @CR & $State[5], 0, $hForm) EndSwitch GUICtrlSetState($Button1, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_ENABLE) GUICtrlSetState($Button4, $GUI_DISABLE) GUICtrlSetData($Progress, 0) GUICtrlSetData($Label, '') GUICtrlSetData($Button3, 'Copy') GUICtrlSetData($Button4, ';') $Copy = 0 EndIf EndIf $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 $Path = FileSelectFolder('Select source folder that to be copied.', '', 2, $Source, $hForm) If $Path Then GUICtrlSetData($Input1, $Path) $Source = $Path EndIf Case $Button2 $Path = FileSelectFolder('Select destination folder in which will be copied the source directory.', '', 2, $Destination, $hForm) If $Path Then GUICtrlSetData($Input2, $Path) $Destination = $Path EndIf Case $Button3 If $Copy Then _Copy_Abort() Else If (Not $Source) Or (Not $Destination) Then MsgBox(16, '', 'The source and destination folders must be specified.', 0, $hForm) ContinueLoop EndIf $Path = $Destination & '\' & StringRegExpReplace($Source, '^.*\\', '') If FileExists($Path) Then If MsgBox(51, 'Copy', $Path & ' already exists.' & @CR & @CR & 'Do you want to merge folders?', 0, $hForm) <> 6 Then ContinueLoop EndIf EndIf GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_DISABLE) GUICtrlSetState($Button4, $GUI_ENABLE) GUICtrlSetData($Label, 'Preparing...') GUICtrlSetData($Button3, 'Abort') _Copy_CopyDir($Source, $Path, 0, 0, 0, '_Copy_CallbackDlg', $hForm) $Copy = 1 EndIf Case $Button4 $Pause = Not $Pause If $Pause Then GUICtrlSetData($Button4, '4') Else GUICtrlSetData($Button4, ';') EndIf _Copy_Pause($Pause) EndSwitch WEnd Edited December 10, 2013 by Yashied ESATU, meoit, mLipok and 1 other 4 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted November 5, 2010 Share Posted November 5, 2010 Yashied You rock.. Thanks for this UDF Best regards, Emiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Yashied Posted November 6, 2010 Author Share Posted November 6, 2010 (edited) Another example of a recursive copying directories (like Explorer). Here the "Source" and "Destination" folders should exist on disk. expandcollapse popup#Include <Copy.au3> #Include <GUIConstantsEx.au3> Opt('GUIOnEventMode', 1) Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) Global Const $Source = 'C:\Source' Global Const $Destination = 'C:\Destination' Global $hForm, $Button, $Label1, $Label2, $Progress1, $Progress2 Global $DirSize, $CurSize, $Abort = False If Not _Copy_OpenDll() Then MsgBox(16, '', 'Copy.dll not found.') Exit EndIf $hForm = GUICreate('Copying', 400, 146) GUISetOnEvent($GUI_EVENT_CLOSE, '_Event') $Label1 = GUICtrlCreateLabel($Destination, 16, 17, 368, 14) GUICtrlSetData(-1, $Destination) $Progress1 = GUICtrlCreateProgress(16, 33, 368, 16) $Label2 = GUICtrlCreateLabel('Prepare...', 16, 63, 368, 14) $Progress2 = GUICtrlCreateProgress(16, 79, 368, 16) $Button = GUICtrlCreateButton('Cancel', 305, 110, 80, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUICtrlSetOnEvent(-1, '_Event') GUISetState() _Copy($Source, $Destination) Switch @error Case 0 MsgBox(64, '', 'The files copying is complete successfully.', 0, $hForm) Case 1235 ; ERROR_REQUEST_ABORTED MsgBox(16, '', 'The files copying was aborted by user.', 0, $hForm) Case Else MsgBox(16, '', 'The files not copied. ' & @CR & @CR & @error, 0, $hForm) EndSwitch _Copy_CloseDll() Func _Event() Switch @GUI_CtrlID Case $GUI_EVENT_CLOSE Exit Case $Button $Abort = 1 EndSwitch EndFunc ;==>_Event Func _Copy($sSource, $sDestination, $fReplace = False, $iFlags = 0, $sRoot = '') Local $sPath, $sFile, $hSearch, $Percent, $Result, $Size, $State, $Error = -1 If Not $sRoot Then $DirSize = DirGetSize($sSource) $CurSize = 0 EndIf $hSearch = FileFindFirstFile($sSource & $sRoot & '\*.*') If $hSearch = -1 Then Switch @error Case 1 ; Folder is empty Case Else Return SetError(-1, 0, 0) EndSwitch EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then FileClose($hSearch) Return 1 EndIf $sPath = $sRoot & '\' & $sFile If @extended Then GUICtrlSetData($Label1, $sDestination & $sPath) If Not FileExists($sDestination & $sPath) Then If Not DirCreate($sDestination & $sPath) Then ExitLoop EndIf FileSetAttrib($sDestination & $sPath, '+' & StringReplace(FileGetAttrib($sSource & $sPath), 'D', '')) EndIf If Not _Copy($sSource, $sDestination, $fReplace, $iFlags, $sPath) Then $Error = @error ExitLoop EndIf Else GUICtrlSetData($Label2, $sFile) GUICtrlSetData($Progress2, 0) $Size = FileGetSize($sSource & $sPath) If @error Then ExitLoop EndIf Do If (Not $fReplace) And (FileExists($sDestination & $sPath)) Then $Result = MsgBox(35, '', $sDestination & $sPath & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $hForm) Switch $Result Case 2 ; "CANCEL" $Error = 1235 ; ERROR_REQUEST_ABORTED ExitLoop 2 Case 7 ; "NO" ExitLoop EndSwitch EndIf If Not _Copy_CopyFile($sSource & $sPath, $sDestination & $sPath, $iFlags) Then ExitLoop 2 EndIf While 1 If $Abort Then _Copy_Abort() EndIf $State = _Copy_GetState() If $State[0] Then $Percent = Round($State[1] / $Size * 100) If GUICtrlRead($Progress2) <> $Percent Then GUICtrlSetData($Progress2, $Percent) EndIf $Percent = Round(($CurSize + $State[1]) / $DirSize * 100) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf Else If Not $State[2] Then GUICtrlSetData($Progress2, 100) Else $Error = $State[2] ExitLoop 3 EndIf ExitLoop 2 EndIf WEnd If Not StringInStr(FileGetAttrib($sSource & $sPath), 'A') Then FileSetAttrib($sDestination & $sPath, '-A') EndIf Until 1 $CurSize += $Size $Percent = Round($CurSize / $DirSize * 100) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf EndIf WEnd FileClose($hSearch) Return SetError($Error, 0, 0) EndFunc ;==>_EnumFiles Edited November 7, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
KaFu Posted November 7, 2010 Share Posted November 7, 2010 You rock.. Thanks for this UDFNot much to add to this one m8 , thanks a lot for the dll fun lately! Â 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...
Emiel Wieldraaijer Posted November 12, 2010 Share Posted November 12, 2010 (edited) Hi Yashied,I believe you should remove the following If Not StringInStr(FileGetAttrib($sSource & $sPath), 'A') Then FileSetAttrib($sDestination & $sPath, '-A') EndIfWiki Archive BitBest regards,Emiel Edited November 12, 2010 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted November 13, 2010 Share Posted November 13, 2010 (edited) Another Example based on the recurvice folder copy example from Yashied expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <UpDownConstants.au3> #include <EditConstants.au3> #include "Copy.au3" If Not _Copy_OpenDll() Then MsgBox(16, '', 'Copy.dll not found.') Exit EndIf Dim $Version = "1.0.0" Dim $Website = "http://www.autoitscript.com" Dim $Menu[7], $Button[4], $Progress1, $Progress2, $Percent, $Size, $State, $Copy = 0 Dim $DirSize[3], $DirSizeAfter[4], $Max[4], $CurSize, $Abort = False Dim $Title = "Copy Folder" $Source = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Source", "") $Destination = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Destination", "") $Days = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Days", "7") $Current = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Current", "") $Erase = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "NO") $GUI = GUICreate($Title, 440, 390) $Menu[1] = GUICtrlCreateMenu("&File") $Menu[4] = GUICtrlCreateMenuItem("E&xit", $Menu[1]) $Menu[2] = GUICtrlCreateMenu("Options") $Menu[5] = GUICtrlCreateMenuItem("&Erase folder ", $Menu[2]) $Menu[3] = GUICtrlCreateMenu("&?") $Menu[6] = GUICtrlCreateMenuItem("Website &AutoItScripts", $Menu[3]) If $Erase = "YES" Then GUICtrlSetState($Menu[5], $GUI_Checked) GUICtrlCreateGroup("Source : ", 10, 20, 415, 55) $SourceInput = GUICtrlCreateInput("", 20, 40, 365, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetData(-1, $Source) $Button[1] = GUICtrlCreateButton("...", 395, 40, 20, 20) GUICtrlSetTip(-1, "Select source folder", "", 0, 2) GUICtrlCreateGroup("Target : ", 10, 80, 415, 55) $DestinationInput = GUICtrlCreateInput("", 20, 100, 365, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetData(-1, $Destination) $Button[2] = GUICtrlCreateButton("...", 395, 100, 20, 20) GUICtrlSetTip(-1, "Select target folder", "", 0, 2) GUICtrlCreateGroup("Status : ", 10, 140, 415, 175) GUICtrlCreateLabel("File...........................", 20, 160, 95, 20) $Label = GUICtrlCreateInput("", 120, 158, 295, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Current...............................", 20, 180, 95, 20) $Progress2 = GUICtrlCreateProgress(120, 178, 295, 20) GUICtrlCreateLabel("Total.............................", 20, 200, 95, 20) $Progress1 = GUICtrlCreateProgress(120, 198, 295, 20) GUICtrlCreateLabel("Files..........................", 20, 240, 95, 20) $TotalFiles = GUICtrlCreateInput("", 120, 238, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Folders..........................", 20, 260, 95, 20) $TotalFolders = GUICtrlCreateInput("", 120, 258, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Size(MB)...................", 20, 280, 95, 20) $CurrentSize = GUICtrlCreateInput("", 120, 278, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) $Last2 = GUICtrlCreateLabel("Last................................", 240, 240, 100, 20) GUICtrlSetTip(-1, "Last subfolder used for Backup", "", 0, 2) $Last = GUICtrlCreateInput("-", 345, 238, 70, 20, $SS_RIGHT) If $Current = "" Then $Current = 1 ElseIf $Current = 1 Then GUICtrlSetData($Last, $Days) Else GUICtrlSetData($Last, $Current - 1) EndIf GUICtrlSetState(-1, $GUI_Disable) $Next2 = GUICtrlCreateLabel("Next...........................", 240, 260, 100, 20) GUICtrlSetTip(-1, "Next subfolder used for Backup", "", 0, 2) $Next = GUICtrlCreateInput($Current, 345, 258, 70, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) $Max[1] = GUICtrlCreateInput($Days, 345, 278, 70, 20, $ES_READONLY + $SS_RIGHT) $Max[2] = GUICtrlCreateLabel("Maximum........................", 240, 280, 100, 20) GUICtrlSetTip(-1, "Maximum subfolders used for Backup", "", 0, 2) $Max[3] = GUICtrlCreateUpdown($Max[1], 0x21) GUICtrlSetLimit(-1, 999, 2) $Button[3] = GUICtrlCreateButton("Copy", 340, 330, 80, 20) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() _ReduceMemory() Func _ButtonControl($Value) For $i = 1 To 3 GUICtrlSetState($Button[$i], $Value) Next EndFunc ;==>_ButtonControl While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _Terminate() Switch $msg Case -100 To 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE _Terminate() Case $msg = $Menu[4] _Terminate() Case $Button[1] $FolderSelect = FileSelectFolder("Select source folder", "", 3, GUICtrlRead($SourceInput)) If $FolderSelect <> "" Then GUICtrlSetData($SourceInput, $FolderSelect) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Source", $FolderSelect) $FolderInfo = DirGetSize($FolderSelect) EndIf Case $Button[2] $FolderSelect = FileSelectFolder("Select target folder", "", 3, GUICtrlRead($DestinationInput)) If $FolderSelect <> "" Then GUICtrlSetData($DestinationInput, $FolderSelect) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Destination", $FolderSelect) EndIf Case $Button[3] If GUICtrlRead($Button[3]) = "Abort" Then $Abort = 1 GUICtrlSetData($Button[3], "Copy") Else IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Days", GUICtrlRead($Max[1])) If GUICtrlRead($SourceInput) = "" Or GUICtrlRead($DestinationInput) = "" Then _ButtonControl($GUI_Disable) MsgBox(16, '', 'The source and destination must be specified.', 0, $GUI) _ButtonControl($GUI_Enable) ElseIf GUICtrlRead($SourceInput) = GUICtrlRead($DestinationInput) Then _ButtonControl($GUI_Disable) MsgBox(16, '', 'The source and destination must be different.', 0, $GUI) _ButtonControl($GUI_Enable) Else GUICtrlSetData($Progress1, 0) GUICtrlSetData($Button[3], "Abort") GUICtrlSetState($Button[1], $GUI_Disable) GUICtrlSetState($Button[2], $GUI_Disable) GUICtrlSetData($Next2, "Current............................") GUICtrlSetTip($Next2, "Current subfolder used for Backup", "", 0, 2) If $Erase = "YES" Then _Flush(GUICtrlRead($DestinationInput) & '\' & $Current) $TimeStart = TimerInit() $sFileCount = 0 $sFolderCount = 0 _CopyData(GUICtrlRead($SourceInput), GUICtrlRead($DestinationInput) & '\' & $Current, True) Switch @error Case 0 $TimeEnd = Round(TimerDiff($TimeStart) / 1000) $DirSizeAfter = DirGetSize(GUICtrlRead($DestinationInput) & '\' & $Current, 1) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(64, '', 'Copied ' & $DirSizeAfter[1] & ' files successfully in ' & $TimeEnd & ' Seconds.', 0, $GUI) Case 1235 ; ERROR_REQUEST_ABORTED $TimeEnd = Round(TimerDiff($TimeStart) / 1000) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(16, '', 'Copy was aborted by user.', 0, $GUI) Case Else $TimeEnd = Round(TimerDiff($TimeStart) / 1000) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(16, '', 'No files were copied. ' & @CR & @CR & @error, 0, $GUI) EndSwitch GUICtrlSetData($Next2, "Next...............") GUICtrlSetTip(-1, "Next subfolder used for Backup", "", 0, 2) $Current = $Current + 1 If $Current > $Days Then $Current = 1 IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Current", $Current) If $Current - 1 = 0 Then GUICtrlSetData($Last, $Days) Else GUICtrlSetData($Last, $Current - 1) EndIf GUICtrlSetData($Next, $Current) GUICtrlSetData($Button[3], "Copy") _ButtonControl($GUI_Enable) EndIf EndIf Case $Menu[6] ShellExecute($Website) Case $Menu[5] If BitAND(GUICtrlRead($Menu[5]), $GUI_Checked) = $GUI_Checked Then GUICtrlSetState($Menu[5], $GUI_UNChecked) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "NO") $Erase = "NO" Else GUICtrlSetState($Menu[5], $GUI_Checked) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "YES") $Erase = "YES" EndIf EndSwitch WEnd ;==> Func _CopyData($sSource, $sDestination, $fReplace = False, $iFlags = 0, $sRoot = '') Local $sPath, $sFile, $hSearch, $Percent, $Result, $Size, $State, $Error = -1 If Not $sRoot Then $DirSize = DirGetSize($sSource, 1) $CurSize = 0 EndIf $hSearch = FileFindFirstFile($sSource & $sRoot & '\*.*') If $hSearch = -1 Then Switch @error Case 1 ; Folder is empty Case Else Return SetError(-1, 0, 0) EndSwitch EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then FileClose($hSearch) Return 1 EndIf $sPath = $sRoot & '\' & $sFile If @extended Then ; folder $sFolderCount = $sFolderCount + 1 GUICtrlSetData($TotalFolders, $sFolderCount & '/' & $DirSize[2]) If Not FileExists($sDestination & $sPath) Then If Not DirCreate($sDestination & $sPath) Then ExitLoop EndIf FileSetAttrib($sDestination & $sPath, '+' & StringReplace(FileGetAttrib($sSource & $sPath), 'D', '')) EndIf If Not _CopyData($sSource, $sDestination, $fReplace, $iFlags, $sPath) Then $Error = @error ExitLoop EndIf Else ; file GUICtrlSetData($Label, $sFile) $sFileCount = $sFileCount + 1 GUICtrlSetData($TotalFiles, $sFileCount & '/' & $DirSize[1]) GUICtrlSetData($Progress2, 0) $Size = FileGetSize($sSource & $sPath) If @error Then ExitLoop EndIf Do If (Not $fReplace) And (FileExists($sDestination & $sPath)) Then ; FileExists $Result = MsgBox(35, '', $sDestination & $sPath & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $GUI) Switch $Result Case 2 ; "CANCEL" $Error = 1235 ; ERROR_REQUEST_ABORTED ExitLoop 2 Case 7 ; "NO" ExitLoop EndSwitch EndIf If Not _Copy_CopyFile($sSource & $sPath, $sDestination & $sPath, $iFlags) Then ExitLoop 2 EndIf While 1 $Msg2 = GUIGetMsg() If $Msg2 = $GUI_EVENT_CLOSE Then _Terminate() Select Case $Msg2 = $Button[3] $Abort = 1 GUICtrlSetData($Progress1, 0) GUICtrlSetData($Progress2, 0) Case $Msg2 = $GUI_EVENT_CLOSE _Terminate() Case $Msg2 = $Menu[4] _Terminate() Case $Msg2 = $Menu[6] ShellExecute($Website) EndSelect If $Abort Then _Copy_Abort() $Abort = False EndIf $State = _Copy_GetState() If $State[0] Then $Percent = Round($State[1] / $Size * 100) If GUICtrlRead($Progress2) <> $Percent Then GUICtrlSetData($Progress2, $Percent) EndIf $Percent = Round(($CurSize + $State[1]) / $DirSize[0] * 100) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf Else If Not $State[2] Then GUICtrlSetData($Progress2, 100) Else $Error = $State[2] ExitLoop 3 EndIf ExitLoop 2 EndIf WEnd ;If Not StringInStr(FileGetAttrib($sSource & $sPath), 'A') Then ; FileSetAttrib($sDestination & '\' & $Current & $sPath, '-A') ;EndIf Until 1 $CurSize += $Size $Percent = Round($CurSize / $DirSize[0] * 100) GUICtrlSetData($CurrentSize, Round($CurSize / 1048576, 0) & '/' & Round($DirSize[0] / 1048576, 0)) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf FileSetAttrib($sDestination & '\' & $Current & $sPath, '+A') EndIf WEnd FileClose($hSearch) Return SetError($Error, 0, 0) EndFunc ;==>_CopyData Func _Terminate() IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Days", GUICtrlRead($Max[1])) _Copy_Abort() _Copy_CloseDll() Exit EndFunc ;==>_Terminate Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Func _Flush($folder) FileSetAttrib($folder & "\*.*", "-RSH", 1) Local $search, $file, $attrib $search = FileFindFirstFile($folder & "\*.*") If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($folder & "\" & $file) If StringInStr($attrib, "D") Then DirRemove($folder & "\" & $file, 1) Else FileDelete($folder & "\" & $file) EndIf WEnd EndIf EndFunc ;==>_Flush Edited November 13, 2010 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
amin84 Posted November 21, 2010 Share Posted November 21, 2010 AWESOME script. Is there anyway to have multiple source and multiple destination? I tried for an hour with no luck! Link to comment Share on other sites More sharing options...
Yashied Posted November 21, 2010 Author Share Posted November 21, 2010 (edited) AWESOME script.Is there anyway to have multiple source and multiple destination? I tried for an hour with no luck!Example 2 from first post. Edited November 21, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
wuruoyu Posted November 21, 2010 Share Posted November 21, 2010 Like leomoon said, awesome script! Yashied Is there a way to copy folder to folder from multiple path $source that is combine into an array list. ex. $arrayItem01 = "C:\1" $arrayItem02 = "C:\2" _arrayAdd($sFolders, $arrayItem01) _arrayAdd($sFolders, $arrayItem02) sFolders as the source folder. and display the total progress properly. Thanks in advanced. Link to comment Share on other sites More sharing options...
wraithdu Posted November 22, 2010 Share Posted November 22, 2010 @wuruoyuThat is not a reasonable UDF request. Write your own wrapper function to utilize this UDF to accomplish your goal. Link to comment Share on other sites More sharing options...
wuruoyu Posted November 22, 2010 Share Posted November 22, 2010 @wraithdu I see. but forgot to mention. I am asking the UDF maker( Yashied ). Maybe this is too difficult everybody else other than Yashied. :-) Link to comment Share on other sites More sharing options...
James Posted November 22, 2010 Share Posted November 22, 2010 @wraithduI see. but forgot to mention. I am asking the UDF maker( Yashied ). Maybe this is too difficult everybody else other than Yashied. :-)No, it's not reasonable for part of the UDF.The idea of a UDF is to allow developers to write their own wrappers around the functions provided. It's up to you to use Copy.au3 to make it act like you want it to.Implementing your idea directly into the source would make it act very strictly, stopping Yashied's examples from working how they do and breaking any scripts that rely on it how it works currently.Your ignorance to this fact makes you even more stupid than not backing away from wraithdu's comment when he fully explained why this would not be done. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
paule Posted November 22, 2010 Share Posted November 22, 2010 @yashied Only work on 32 Bit. I have a German 64Bit Windows 7 Ultimate OS $__cpDll = DllOpen($sDll) If $__cpDll = -1 Then Return SetError(1, 0, 0) EndIf On 64Bit the result $__cpDll is always -1. XP 32Bit is ok $__cpDll=1 Link to comment Share on other sites More sharing options...
wraithdu Posted November 22, 2010 Share Posted November 22, 2010 (edited) @paule I guess the DLL for this UDF is a 32-bit DLL. Just compile your script as a 32-bit executable and you'll be fine. 64-bit executables cannot load 32-bit DLLs and vice-versa. Edited November 22, 2010 by wraithdu Link to comment Share on other sites More sharing options...
freMea Posted November 22, 2010 Share Posted November 22, 2010 Another Example based on the recurvice folder copy example from Yashied expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <UpDownConstants.au3> #include <EditConstants.au3> #include "Copy.au3" If Not _Copy_OpenDll() Then MsgBox(16, '', 'Copy.dll not found.') Exit EndIf Dim $Version = "1.0.0" Dim $Website = "http://www.autoitscript.com" Dim $Menu[7], $Button[4], $Progress1, $Progress2, $Percent, $Size, $State, $Copy = 0 Dim $DirSize[3], $DirSizeAfter[4], $Max[4], $CurSize, $Abort = False Dim $Title = "Copy Folder" $Source = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Source", "") $Destination = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Destination", "") $Days = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Days", "7") $Current = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Current", "") $Erase = IniRead(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "NO") $GUI = GUICreate($Title, 440, 390) $Menu[1] = GUICtrlCreateMenu("&File") $Menu[4] = GUICtrlCreateMenuItem("E&xit", $Menu[1]) $Menu[2] = GUICtrlCreateMenu("Options") $Menu[5] = GUICtrlCreateMenuItem("&Erase folder ", $Menu[2]) $Menu[3] = GUICtrlCreateMenu("&?") $Menu[6] = GUICtrlCreateMenuItem("Website &AutoItScripts", $Menu[3]) If $Erase = "YES" Then GUICtrlSetState($Menu[5], $GUI_Checked) GUICtrlCreateGroup("Source : ", 10, 20, 415, 55) $SourceInput = GUICtrlCreateInput("", 20, 40, 365, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetData(-1, $Source) $Button[1] = GUICtrlCreateButton("...", 395, 40, 20, 20) GUICtrlSetTip(-1, "Select source folder", "", 0, 2) GUICtrlCreateGroup("Target : ", 10, 80, 415, 55) $DestinationInput = GUICtrlCreateInput("", 20, 100, 365, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetData(-1, $Destination) $Button[2] = GUICtrlCreateButton("...", 395, 100, 20, 20) GUICtrlSetTip(-1, "Select target folder", "", 0, 2) GUICtrlCreateGroup("Status : ", 10, 140, 415, 175) GUICtrlCreateLabel("File...........................", 20, 160, 95, 20) $Label = GUICtrlCreateInput("", 120, 158, 295, 20) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Current...............................", 20, 180, 95, 20) $Progress2 = GUICtrlCreateProgress(120, 178, 295, 20) GUICtrlCreateLabel("Total.............................", 20, 200, 95, 20) $Progress1 = GUICtrlCreateProgress(120, 198, 295, 20) GUICtrlCreateLabel("Files..........................", 20, 240, 95, 20) $TotalFiles = GUICtrlCreateInput("", 120, 238, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Folders..........................", 20, 260, 95, 20) $TotalFolders = GUICtrlCreateInput("", 120, 258, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel("Size(MB)...................", 20, 280, 95, 20) $CurrentSize = GUICtrlCreateInput("", 120, 278, 110, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) $Last2 = GUICtrlCreateLabel("Last................................", 240, 240, 100, 20) GUICtrlSetTip(-1, "Last subfolder used for Backup", "", 0, 2) $Last = GUICtrlCreateInput("-", 345, 238, 70, 20, $SS_RIGHT) If $Current = "" Then $Current = 1 ElseIf $Current = 1 Then GUICtrlSetData($Last, $Days) Else GUICtrlSetData($Last, $Current - 1) EndIf GUICtrlSetState(-1, $GUI_Disable) $Next2 = GUICtrlCreateLabel("Next...........................", 240, 260, 100, 20) GUICtrlSetTip(-1, "Next subfolder used for Backup", "", 0, 2) $Next = GUICtrlCreateInput($Current, 345, 258, 70, 20, $SS_RIGHT) GUICtrlSetState(-1, $GUI_Disable) $Max[1] = GUICtrlCreateInput($Days, 345, 278, 70, 20, $ES_READONLY + $SS_RIGHT) $Max[2] = GUICtrlCreateLabel("Maximum........................", 240, 280, 100, 20) GUICtrlSetTip(-1, "Maximum subfolders used for Backup", "", 0, 2) $Max[3] = GUICtrlCreateUpdown($Max[1], 0x21) GUICtrlSetLimit(-1, 999, 2) $Button[3] = GUICtrlCreateButton("Copy", 340, 330, 80, 20) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() _ReduceMemory() Func _ButtonControl($Value) For $i = 1 To 3 GUICtrlSetState($Button[$i], $Value) Next EndFunc ;==>_ButtonControl While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _Terminate() Switch $msg Case -100 To 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE _Terminate() Case $msg = $Menu[4] _Terminate() Case $Button[1] $FolderSelect = FileSelectFolder("Select source folder", "", 3, GUICtrlRead($SourceInput)) If $FolderSelect <> "" Then GUICtrlSetData($SourceInput, $FolderSelect) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Source", $FolderSelect) $FolderInfo = DirGetSize($FolderSelect) EndIf Case $Button[2] $FolderSelect = FileSelectFolder("Select target folder", "", 3, GUICtrlRead($DestinationInput)) If $FolderSelect <> "" Then GUICtrlSetData($DestinationInput, $FolderSelect) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Destination", $FolderSelect) EndIf Case $Button[3] If GUICtrlRead($Button[3]) = "Abort" Then $Abort = 1 GUICtrlSetData($Button[3], "Copy") Else IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Days", GUICtrlRead($Max[1])) If GUICtrlRead($SourceInput) = "" Or GUICtrlRead($DestinationInput) = "" Then _ButtonControl($GUI_Disable) MsgBox(16, '', 'The source and destination must be specified.', 0, $GUI) _ButtonControl($GUI_Enable) ElseIf GUICtrlRead($SourceInput) = GUICtrlRead($DestinationInput) Then _ButtonControl($GUI_Disable) MsgBox(16, '', 'The source and destination must be different.', 0, $GUI) _ButtonControl($GUI_Enable) Else GUICtrlSetData($Progress1, 0) GUICtrlSetData($Button[3], "Abort") GUICtrlSetState($Button[1], $GUI_Disable) GUICtrlSetState($Button[2], $GUI_Disable) GUICtrlSetData($Next2, "Current............................") GUICtrlSetTip($Next2, "Current subfolder used for Backup", "", 0, 2) If $Erase = "YES" Then _Flush(GUICtrlRead($DestinationInput) & '\' & $Current) $TimeStart = TimerInit() $sFileCount = 0 $sFolderCount = 0 _CopyData(GUICtrlRead($SourceInput), GUICtrlRead($DestinationInput) & '\' & $Current, True) Switch @error Case 0 $TimeEnd = Round(TimerDiff($TimeStart) / 1000) $DirSizeAfter = DirGetSize(GUICtrlRead($DestinationInput) & '\' & $Current, 1) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(64, '', 'Copied ' & $DirSizeAfter[1] & ' files successfully in ' & $TimeEnd & ' Seconds.', 0, $GUI) Case 1235 ; ERROR_REQUEST_ABORTED $TimeEnd = Round(TimerDiff($TimeStart) / 1000) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(16, '', 'Copy was aborted by user.', 0, $GUI) Case Else $TimeEnd = Round(TimerDiff($TimeStart) / 1000) GUICtrlSetState($Button[3], $GUI_Disable) MsgBox(16, '', 'No files were copied. ' & @CR & @CR & @error, 0, $GUI) EndSwitch GUICtrlSetData($Next2, "Next...............") GUICtrlSetTip(-1, "Next subfolder used for Backup", "", 0, 2) $Current = $Current + 1 If $Current > $Days Then $Current = 1 IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Current", $Current) If $Current - 1 = 0 Then GUICtrlSetData($Last, $Days) Else GUICtrlSetData($Last, $Current - 1) EndIf GUICtrlSetData($Next, $Current) GUICtrlSetData($Button[3], "Copy") _ButtonControl($GUI_Enable) EndIf EndIf Case $Menu[6] ShellExecute($Website) Case $Menu[5] If BitAND(GUICtrlRead($Menu[5]), $GUI_Checked) = $GUI_Checked Then GUICtrlSetState($Menu[5], $GUI_UNChecked) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "NO") $Erase = "NO" Else GUICtrlSetState($Menu[5], $GUI_Checked) IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Erase", "YES") $Erase = "YES" EndIf EndSwitch WEnd ;==> Func _CopyData($sSource, $sDestination, $fReplace = False, $iFlags = 0, $sRoot = '') Local $sPath, $sFile, $hSearch, $Percent, $Result, $Size, $State, $Error = -1 If Not $sRoot Then $DirSize = DirGetSize($sSource, 1) $CurSize = 0 EndIf $hSearch = FileFindFirstFile($sSource & $sRoot & '\*.*') If $hSearch = -1 Then Switch @error Case 1 ; Folder is empty Case Else Return SetError(-1, 0, 0) EndSwitch EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then FileClose($hSearch) Return 1 EndIf $sPath = $sRoot & '\' & $sFile If @extended Then ; folder $sFolderCount = $sFolderCount + 1 GUICtrlSetData($TotalFolders, $sFolderCount & '/' & $DirSize[2]) If Not FileExists($sDestination & $sPath) Then If Not DirCreate($sDestination & $sPath) Then ExitLoop EndIf FileSetAttrib($sDestination & $sPath, '+' & StringReplace(FileGetAttrib($sSource & $sPath), 'D', '')) EndIf If Not _CopyData($sSource, $sDestination, $fReplace, $iFlags, $sPath) Then $Error = @error ExitLoop EndIf Else ; file GUICtrlSetData($Label, $sFile) $sFileCount = $sFileCount + 1 GUICtrlSetData($TotalFiles, $sFileCount & '/' & $DirSize[1]) GUICtrlSetData($Progress2, 0) $Size = FileGetSize($sSource & $sPath) If @error Then ExitLoop EndIf Do If (Not $fReplace) And (FileExists($sDestination & $sPath)) Then ; FileExists $Result = MsgBox(35, '', $sDestination & $sPath & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $GUI) Switch $Result Case 2 ; "CANCEL" $Error = 1235 ; ERROR_REQUEST_ABORTED ExitLoop 2 Case 7 ; "NO" ExitLoop EndSwitch EndIf If Not _Copy_CopyFile($sSource & $sPath, $sDestination & $sPath, $iFlags) Then ExitLoop 2 EndIf While 1 $Msg2 = GUIGetMsg() If $Msg2 = $GUI_EVENT_CLOSE Then _Terminate() Select Case $Msg2 = $Button[3] $Abort = 1 GUICtrlSetData($Progress1, 0) GUICtrlSetData($Progress2, 0) Case $Msg2 = $GUI_EVENT_CLOSE _Terminate() Case $Msg2 = $Menu[4] _Terminate() Case $Msg2 = $Menu[6] ShellExecute($Website) EndSelect If $Abort Then _Copy_Abort() $Abort = False EndIf $State = _Copy_GetState() If $State[0] Then $Percent = Round($State[1] / $Size * 100) If GUICtrlRead($Progress2) <> $Percent Then GUICtrlSetData($Progress2, $Percent) EndIf $Percent = Round(($CurSize + $State[1]) / $DirSize[0] * 100) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf Else If Not $State[2] Then GUICtrlSetData($Progress2, 100) Else $Error = $State[2] ExitLoop 3 EndIf ExitLoop 2 EndIf WEnd ;If Not StringInStr(FileGetAttrib($sSource & $sPath), 'A') Then ; FileSetAttrib($sDestination & '\' & $Current & $sPath, '-A') ;EndIf Until 1 $CurSize += $Size $Percent = Round($CurSize / $DirSize[0] * 100) GUICtrlSetData($CurrentSize, Round($CurSize / 1048576, 0) & '/' & Round($DirSize[0] / 1048576, 0)) If GUICtrlRead($Progress1) <> $Percent Then GUICtrlSetData($Progress1, $Percent) EndIf FileSetAttrib($sDestination & '\' & $Current & $sPath, '+A') EndIf WEnd FileClose($hSearch) Return SetError($Error, 0, 0) EndFunc ;==>_CopyData Func _Terminate() IniWrite(@ScriptDir & "\CFBackup.ini", "Settings", "Days", GUICtrlRead($Max[1])) _Copy_Abort() _Copy_CloseDll() Exit EndFunc ;==>_Terminate Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Func _Flush($folder) FileSetAttrib($folder & "\*.*", "-RSH", 1) Local $search, $file, $attrib $search = FileFindFirstFile($folder & "\*.*") If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($folder & "\" & $file) If StringInStr($attrib, "D") Then DirRemove($folder & "\" & $file, 1) Else FileDelete($folder & "\" & $file) EndIf WEnd EndIf EndFunc ;==>_Flush You're example doesn't work at home (XP PRO SP3, AutoIt v3.3.6.1) "No files were copied". The source folder contains 5 files and the target folder is empty. What did I miss? ESATU 1 [list][*]AutoIt 3.3.8.1[*]Win XP PRO SP3[/list] Link to comment Share on other sites More sharing options...
wraithdu Posted November 22, 2010 Share Posted November 22, 2010 The short bus maybe? How is anyone supposed to try to help you when you've provided absolutely no information that is even slightly useful? Link to comment Share on other sites More sharing options...
freMea Posted November 23, 2010 Share Posted November 23, 2010 The short bus maybe? How is anyone supposed to try to help you when you've provided absolutely no information that is even slightly useful?Sorry, I'm a noob and I don't know yet what I can say more about it. But, it would be helpful if I was just told the script I mention above works for someone or not.Cheers [list][*]AutoIt 3.3.8.1[*]Win XP PRO SP3[/list] Link to comment Share on other sites More sharing options...
wuruoyu Posted November 23, 2010 Share Posted November 23, 2010 (edited) wow, cannot believe some people here are very impatient, rarher than write 100 words to express your own point of view. for honest people would just say i dont know or a good programmer would instead posting something more useful to help people on this forum. isn't that the whole point. and thanks you. i solved my array problem. :-) Edited November 23, 2010 by wuruoyu Link to comment Share on other sites More sharing options...
wraithdu Posted November 23, 2010 Share Posted November 23, 2010 (edited) Why don't you save your own 100 words and come up with a solution to your own problem? This forum is about helping people, not spoon feeding them some code they wouldn't understand anyway. Most of the people commenting in this thread are more than capable of solving your problem in 10 minutes. But it's your problem. What would you learn if we did it for you? If you've solved your problem already, then great, hopefully you've learned something along the way. Otherwise post something that shows you've at least put in some effort and you're more likely to get a helpful response.@freMeaOdds are if the example was posted, then it at least works for him. If you're so much a noob that you are unable to provide relevant information regarding your errors, then maybe you're not ready for this UDF. Just saying...... and yes, I'm impatient today. Edited November 23, 2010 by wraithdu Link to comment Share on other sites More sharing options...
Yashied Posted November 23, 2010 Author Share Posted November 23, 2010 (edited) @pauleCopy_x64.dll or download it again from the first post. Use the following:_Copy_OpenDll(@ScriptDir & '\Copy_x64.dll') Edited November 23, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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