#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include "Copy.au3"
Global $Copy = False,$Path,$State,$Data
If Not _Copy_OpenDll() Then
MsgBox(16, '', 'DLL not found.')
Exit
EndIf
$Source1 = @ScriptDir&'\na_flesh'
$Destination1 = 'G:\'
$Source2 = 'h:\A386'
$Destination2 = 'G:\'
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 295, 287, 345, 175)
$Button_Start = GUICtrlCreateButton("Старт", 72, 96, 121, 33)
$Progress = GUICtrlCreateProgress(0, 152, 289, 25)
$Label = GUICtrlCreateLabel("", 0, 192, 292, 28)
$Label1 = GUICtrlCreateLabel("", 0, 230, 292, 28)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_Start
Start()
EndSwitch
WEnd
Func Start()
GUICtrlSetData($Label1, 'Func_1')
Copy_Start($Source1,$Destination1,1)
GUICtrlSetData($Label1, 'Func_2')
Copy_Start($Source2,$Destination2,0)
GUICtrlSetData($Label1, 'Func_End')
EndFunc
Func Copy_Start($Source, $Destination, $Pr_Path)
$res = Copy_Dir($Source,$Destination,$Pr_Path)
If $res < 0 Then Return -1
While 1
If $Copy Then
$State = _Copy_GetState()
If $State[0] Then
If $State[0] = -1 Then
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, $Form1)
Case 1235
MsgBox(16, '', 'Folder copying was aborted.', 0, $Form1)
Case Else
MsgBox(16, '', 'Folder was not copied.' & @CR & @CR & $State[5], 0, $Form1)
EndSwitch
GUICtrlSetState($Button_Start, $GUI_ENABLE)
GUICtrlSetData($Progress, 0)
GUICtrlSetData($Label, '')
GUICtrlSetData($Button_Start, 'Старт')
$Copy = 0
ExitLoop
EndIf
EndIf
WEnd
EndFunc
Func Copy_Dir($Source, $Destination,$Pr_Path)
If $Copy Then
_Copy_Abort()
Else
If (Not $Source) Or (Not $Destination) Then
MsgBox(16, '', 'The source and destination folders must be specified.', 0, $Form1)
Return -1
EndIf
If $Pr_Path Then
$Path = $Destination
Else
$Path = $Destination & '\' & StringRegExpReplace($Source, '^.*\\', '')
EndIf
If FileExists($Path) And $Pr_Path = 0 Then
If MsgBox(52, '', $Path & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $Form1) <> 6 Then
Return -1
EndIf
EndIf
GUICtrlSetState($Button_Start, $GUI_DISABLE)
GUICtrlSetData($Button_Start, 'Отменить')
_Copy_CopyDir($Source, $Path)
$Copy = 1
EndIf
Return 1
EndFunc