Oder so...
_CopyWhithProgress
AutoIt
;-- TIME_STAMP 2017-05-12 21:48:19
#Region ;************ Includes ************
#include-once
#Include <FileConstants.au3>
#include <WinAPIShPath.au3>
#EndRegion ;************ Includes ************
Local $iCopy = Example()
If @error Then MsgBox(262160, '_CopyWhithProgress', "$iCopy --> " & $iCopy & @CRLF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @CRLF)
Func Example()
Local $sCopyFrom = FileOpenDialog('Was soll kopiert werden?', @DesktopDir, 'All (*.*)', $FD_PATHMUSTEXIST) ; $hWnd)
If @error Then Return SetError(@error +1, 1, '$sCopyFrom = ' & $sCopyFrom)
Local $sCopyTo = FileSaveDialog('Wohin soll es kopiert werden?', @DesktopDir, 'All (*.*)', $FD_PATHMUSTEXIST, StringInStr(FileGetAttrib($sCopyFrom), 'D') ? $sCopyFrom : _WinAPI_PathStripPath($sCopyFrom)) ; $hWnd)
If @error Then Return SetError(@error +2, 2, '$sCopyTo = ' & $sCopyTo)
_CopyWhithProgress($sCopyFrom, $sCopyTo)
If @error Then Return SetError(@error +3, 3, '_FileCopy()')
EndFunc
; Windows - copy with progress
; Author - JdeB
;~ 4 Do not display a progress dialog box.
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.
;~ 64 Preserve undo information, if possible.
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.
;~ 256 Display a progress dialog box but do not show the file names.
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.
;~ 1024 Do not display a user interface if an error occurs.
;~ 2048 Version 4.71. Do not copy the security attributes of the file.
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories.
;~ 8192 Version 5.0. Do not copy connected files as a group. Only copy the specified files.
Func _CopyWhithProgress($sCopyFrom, $sCopyTo)
Local $FOF_RESPOND_YES = 16
Local $FOF_SIMPLEPROGRESS = 256
$oShell = ObjCreate("shell.application")
If Not IsObj($oShell) Then Return SetError(3, 3, '$oShell = ' & $oShell)
Local $iDirCreate, $sCopyTargetDir = StringInStr(FileGetAttrib($sCopyTo), 'D') ? $sCopyTo : _WinAPI_PathStripPath($sCopyTo)
If Not FileExists($sCopyTargetDir) Then $iDirCreate = DirCreate($sCopyTargetDir)
If $iDirCreate = 0 Then Return SetError(4, 4, '$iDirCreate = ' & $iDirCreate)
$oShell.namespace($sCopyTo).CopyHere($sCopyFrom, $FOF_RESPOND_YES)
Return True
EndFunc
Alles anzeigen