复制文件夹的问题!
DirCopy("C:\Program Files\Tencent\QQ2008", "d:\QQ2008", 1)我需要带上进度条,应该怎么做?
[ 本帖最后由 浅绿 于 2008-5-11 09:59 编辑 ] 呃.这个我也想知道..如果不判断文件数量就很容易了..事先做个进度条出来到时候调用就行了...
DirCopy 这函数拷贝文件....那速度不是一般人能忍受的.. 我在学校的计算机上保留着一个函数集?是叫函数集?不知道在什么地方下载的,说用那个函数集可以复制文件带上进度条,不过不会使用。。
DirCopy 这函数拷贝文件....那速度不是一般人能忍受的..
难道 考文件夹还有其它命令吗? 帮助中的例子:
ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
sleep(1000)
ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
根据 目标文件夹的大小/总文件的大小
回复 1# 浅绿 的帖子
顶一下吧!!!!!! 举例。。举例。。谢谢。:face (37): #include <GUIConstants.au3>ProgressCopy("D:\Images", "e:\Backup\",1);要复制的文件
Func ProgressCopy($current, $destination, $UseMultiColour=0, $attrib = "-R", $overwrite = 1 ,$Run1 = 0 )
;FirstTimeRun Get original DirSize and set up Gui
If $Run1 = 0 Then
Global $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $LocalPercent
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
If not FileExists ($Destination) then DirCreate ($Destination); This is why it was failing, the dir did not exist
$source = $current
If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1)
If StringRight($destination, 1) <> '\' Then $destination = $destination & "\"
$tosearch = $current
$Overall = DirGetSize($tosearch, 1)
$OverallQty = $Overall
Global Const $PrCopyGui = GUICreate("Copying Files", 420, 100, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$Progress0Text = GUICtrlCreateLabel("Please Wait", 10, 5, 400, 20, $SS_LEFTNOWORDWRAP)
$progressbar1 = GUICtrlCreateProgress(10, 20, 400, 20)
GUICtrlSetColor(-1, 32250)
$Progress1Text = GUICtrlCreateLabel("", 10, 44, 400, 20, $SS_LEFTNOWORDWRAP)
$progressbar2 = GUICtrlCreateProgress(10, 60, 400, 20, $PBS_SMOOTH)
$Progress2Text = GUICtrlCreateLabel("", 10, 82, 400, 20, $SS_LEFTNOWORDWRAP)
GUISetFont(10, 600)
;$Progress2Text2 = GUICtrlCreateLabel("", 150, 62, 400, 20)
GUICtrlSetColor(-1, 32250); not working with Windows XP Style if not using windows classic style or dllcall above
GUISetState(@SW_SHOW)
GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch)
$Run1 = 1
EndIf
$Size = DirGetSize($current, 3)
$Qty = $Size
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
$Qty -= 1
$LocalPercent = 100 - (($Qty / $Size) * 100)
$OverallQty -= 1
$overallpercent = 100 - (($OverallQty / $Overall) * 100)
GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed")
GUICtrlSetData($progressbar1, $overallpercent)
GUICtrlSetData($progressbar2, $LocalPercent)
GUICtrlSetData($Progress2Text, "Copying File " & $file)
If $useMultiColour then
GUICtrlSetColor($Progressbar2, _ChangeColour($LocalPercent))
GUICtrlSetColor($Progressbar1, _ChangeColour($OverallPercent))
EndIf
FileCopy($current & "\" & $file, $destination & StringTrimLeft($current, StringLen($source)) & "\" & $file,$overwrite)
FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, $attrib)
EndIf
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
DirCreate($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file)
FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, $attrib)
GUICtrlSetData($Progress1Text, $current & "\" & $file)
ProgressCopy($current & "\" & $file, $destination, $UseMultiColour, $attrib, $overwrite,1)
EndIf
WEnd
FileClose($search)
;when overall percent = 100 set end gui text, delete gui and reset run1 to 0
If $overallpercent = 100 Then
GUICtrlSetData($Progress0Text, "Total Progress 100% completed")
GUICtrlSetData($progressbar1, 100)
GUICtrlSetData($progressbar2, 100)
GUICtrlSetData($Progress2Text, "Done!")
Sleep(2000)
GUIDelete($PRCopyGui)
$Run1 = 0
EndIf
EndFunc ;==>ProgressCopy
Func _ChangeColour($start)
$Redness = Int(255 - ($start / 100 * 512))
If $Redness < 0 Then $Redness = 0
$Greeness = Int(($start / 100 * 512) - 257)
If $Greeness < 0 Then $Greeness = 0
$Blueness = Int(255 - ($Redness + $Greeness))
Return ($Redness * 256 * 256) + ($Greeness * 256) + $Blueness
EndFunc 原帖由 马甲 于 2008-5-7 13:55 发表 http://www.autoitx.com/images/common/back.gif
#include
ProgressCopy("D:\Images", "e:\Backup\",1);要复制的文件
Func ProgressCopy($current, $destination, $UseMultiColour=0, $attrib = "-R", $overwrite = 1 ,$Run1 = 0 )
;FirstTimeRun Get origi ...
请注明使用编译版本,3.2.9.3.1运行出错。
[ 本帖最后由 华杰 于 2008-5-7 14:23 编辑 ] 原帖由 马甲 于 2008-5-7 13:55 发表 http://www.autoitx.com/images/common/back.gif
#include
ProgressCopy("D:\Images", "e:\Backup\",1);要复制的文件
Func ProgressCopy($current, $destination, $UseMultiColour=0, $attrib = "-R", $overwrite = 1 ,$Run1 = 0 )
;FirstTimeRun Get origi ...
我用3.2.5.5.1版本运行的时候没错...这代码好哇:face (29): 不知道楼主要的什么效果?
提供一个供参考:
_FileCopy('d:\autoit3','d:\aaa');注意,此处路径必须确实存在
Func _FileCopy($fromFile,$tofile)
Local $FOF_RESPOND_YES = 16
Local $FOF_SIMPLEPROGRESS = 16
$winShell = ObjCreate("shell.application")
$winShell.namespace($tofile).CopyHere($fromFile,$FOF_SIMPLEPROGRESS)
EndFunc
关于参数$FOF_SIMPLEPROGRESS
#cs
Folder.CopyHere(vItem [, vOptions])
Parameters
vItem Required. The item or items to copy. This can be a string that represents a file name, a FolderItem object, or a FolderItems object.
vOptions Optional. Options for the copy operation. This value can be zero or a combination of the following values. These values are based upon flags defined for use with the fFlags member of the C++ SHFILEOPSTRUCT structure. These flags are not defined as such for Microsoft Visual Basic, Visual Basic Scripting Edition (VBScript), or Microsoft JScript, so you must define them yourself or use their numeric equivalents.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.
9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.
http://msdn2.microsoft.com/en-us/library/ms630707.aspx
#ce 谢谢各位。
pcbar版主的这个可以使用。我想要ProgressSet(100 , "Done", "Complete")这种类型的。
马甲发的那段代码,我用我们论坛上的Autoit2.11.1运行的时候提示出错,即便把那些都声明了,还是不行,能不能优化一下适合论坛版本使用的? 如果你没有打错字,Autoit2.11.1相信是没有几个人会将以上脚本改到可以运行的了。
还有10楼的例子,相信应该是最简单的了。直接调用系统的。非常好用。 --_--#!
就你眼睛好使。。
打错字啦。。我现在安装的是3.2.11.1.1:face (22): 如果你的真的看上边的不明白。用10楼的例子吧。 我用FileInstall编写脚本打包成exe文件,要怎么编写加入显示进度呢?
页:
[1]
2