#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include "Copy.au3"
Global $Copy = False,$State,$Data
If Not _Copy_OpenDll() Then
MsgBox(16, '', 'DLL not found.')
Exit
EndIf
$Source1 = @ScriptDir&'\na_flesh'
$Destination1 = 'G:\'
$Source2 = 'h:\BCDW\ACRONIS.ISO'
$Destination2 = 'G:\ACRONIS.ISO'
$Source3 = 'h:\A386'
$Destination3 ='G:\A386'
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 295, 287, 345, 175)
$Button_Start = GUICtrlCreateButton("Старт", 72, 96, 121, 33)
$Button_Stop = GUICtrlCreateButton("Стоп", 72, 96, 121, 33)
GUICtrlSetState($Button_Stop,$GUI_HIDE)
$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)
GUICtrlSetData($Label1, 'Func_2')
Copy_Start($Source2,$Destination2)
;Copy_Start($Source3,$Destination3)
GUICtrlSetData($Label1, 'Func_End')
EndFunc ; ===>Start()
Func Copy_Start($Source, $Destination)
$res = Copy_File_Dir($Source,$Destination)
If $res < 0 Then Return -1
While 1
;-----copy----
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, '', 'Данные успешно скопированы.', 0, $Form1)
GUICtrlSetData($Label, 'Данные успешно скопированы.')
Case 1235 ; ERROR_REQUEST_ABORTED
MsgBox(16, '', 'Копирование было прервано.', 0, $Form1)
Case Else
MsgBox(16, '', 'Данные не были скопированы.' & @CR & @CR & $State[5], 0, $Form1)
EndSwitch
;GUICtrlSetState($Button_Start, $GUI_ENABLE)
GUICtrlSetState($Button_Start, $GUI_SHOW)
GUICtrlSetState($Button_Stop, $GUI_HIDE)
GUICtrlSetData($Progress, 0)
GUICtrlSetData($Label, 'Данные успешно скопированы.')
$Copy = 0
ExitLoop
EndIf
EndIf
;Sleep(1)
;----end copy-----
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_Stop
_Copy_Abort()
EndSwitch
WEnd
EndFunc ;===>Copy_Start()
Func Copy_File_Dir($Source, $Destination)
If (Not $Source) Or (Not $Destination) Then
MsgBox(16, '', 'Источник и назначение не определены', 0, $Form1)
Return -1
;ContinueLoop
EndIf
If FileExists($Destination) And StringLen($Destination) >3 Then
If MsgBox(36, '', $Destination & ' уже существует.' & @CR & @CR & 'Заменить?', 0, $Form1) <> 6 Then
Return -1
;ContinueLoop
EndIf
GUICtrlSetData($Label, 'Удаление ' & $Destination)
If StringInStr(FileGetAttrib($Source), "D") = 0 Then
If StringInStr(FileGetAttrib($Destination), "R") <> 0 Then FileSetAttrib($Destination,'-R+N')
FileDelete($Destination)
Else
DirRemove($Destination,1)
EndIf
EndIf
;GUICtrlSetState($Button_Start, $GUI_DISABLE)
GUICtrlSetState($Button_Start, $GUI_HIDE)
GUICtrlSetState($Button_Stop, $GUI_SHOW)
If StringInStr(FileGetAttrib($Source), "D") = 0 Then
_Copy_CopyFile($Source, $Destination)
Else
_Copy_CopyDir($Source, $Destination)
EndIf
$Copy = 1
Return 1
EndFunc ; ===>Copy_Dir()