• 欢迎访问奇跡の海网站,本站不上传任何资源,所有资源均来自于网络,欢迎加入奇跡の海~!奇跡の海-WordPress QQ群
  • 本站下载资源为网络上收集整理而来,并且以计算机技术研究交流为目的,版权归原作者所有,仅供大家参考,学习,不存在任何商业目的与商业用途.
  • 本站系统镜像均来自于官方原版,ed2k可视为P2P下载链接。所有操作系统默认均为试用版,如有正版密钥可以有效激活,本站不提供任何激活和相关服务。

AutoIt3(au3)源码-带进度条的复制

AutoIT3 奇跡の海 2年前 (2018-01-01) 960次浏览 已收录 0个评论 扫描二维码

源码简介

AutoIt3(au3)源码-带进度条的复制
带进度条的复制,超漂亮,第二行路径要修改实际的

AU3源码

#include <GUIConstants.au3> 
ProgressCopy("D:\Code", "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[1] 
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[1] 
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[1]) * 100) 
$OverallQty -= 1 
$overallpercent = 100 - (($OverallQty / $Overall[1]) * 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 

版权声明:本站所有文章和资源使用CC BY-NC-SA 4.0协议授权发布 , 转载应当以相同方式注明文章来自“SeaOMC.COM->AutoIt3(au3)源码-带进度条的复制!在下边可以分享本文哦!
喜欢 (0)
[]
分享 (0)
奇跡の海
关于作者:
一个WordPress菜鸟!
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址