#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("QQ2009 下载器", 330, 74)
$Progress1 = GUICtrlCreateProgress(8, 8, 313, 25)
$Button1 = GUICtrlCreateButton("开始下载", 88, 40, 113, 25, $BS_DEFPUSHBUTTON)
$Button2 = GUICtrlCreateButton("取消下载", 208, 40, 113, 25, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("未下载", 8, 48, 72, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
InetGet("http://dl_dir.qq.com/qqfile/qq/QQ2009preview4/QQ2009Preview4_chs.exe",@ScriptDir & "\qq.exe", 1, 1)
While @InetGetActive
If GUIGetMsg() = $Button2 Then
InetGet("abort")
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)
GUICtrlSetData($Label1,"未下载")
MsgBox(0,"QQ2009 下载器","下载已取消!")
ExitLoop
EndIf
If GUIGetMsg() = $GUI_EVENT_CLOSE Then
Exit
EndIf
Sleep(1000)
If @InetGetActive = 0 Then
MsgBox(0,"QQ2009 下载器","下载完成!")
Exit
EndIf
$baifenbi1 = 18298176 / 100
$baifenbi = @InetGetBytesRead / $baifenbi1
GUICtrlSetData($Progress1,$baifenbi)
GUICtrlSetData($Label1,@InetGetBytesRead & " 字节")
WEnd
EndSwitch
WEnd
为什么点击“取消下载”半天才有反映。。。
[ 本帖最后由 78391493 于 2008-12-20 09:31 编辑 ] |