#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 333, 145, 733, 411)
$Progress1 = GUICtrlCreateProgress(16, 96, 305, 25)
$Label1 = GUICtrlCreateLabel("百分比", 32, 24, 40, 17)
;~ $Label2 = GUICtrlCreateLabel("剩余时间 ", 152, 24, 61, 17)
;~ $Label3 = GUICtrlCreateLabel("速度 ", 160, 56, 37, 17)
GUISetState(@SW_SHOW)
$DLurl="http://autoit-cn.googlecode.com/files/AUTOIT_3.3.1.1-2.exe"
$remotesize=InetGetSize($DLurl)
InetGet($DLurl,"offline.rar",1,1)
While @InetGetActive
;~ Sleep(1)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
fresh()
WEnd
Func fresh()
$localsize=@InetGetBytesRead
GUICtrlSetData($Label1,Round($localsize/$remotesize*100,2) & "%")
GUICtrlSetData($Progress1,$localsize/$remotesize*100)
EndFunc
在while那一段里面.如果sleep500.那么百分比的更新就是一秒两次;如果sleep1就是实时更新,但是为什么sleep500的时候GUI里面的按钮(右上角的X)就不起作用呢...CPU占用率也稍高了...
代码很烂..各位将就看..灰常感谢了... |