本帖最后由 afan 于 2009-9-9 00:15 编辑 #include <GUIConstantsEx.au3>
Dim $timez = 20, $time = $timez
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel($time & "秒后将安装拖拉机,请选择!", 20, 32, 310, 28, 0x0002)
GUICtrlSetFont(-1, 16, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("立即安装(&Y)", 53, 128, 90, 25)
$Button2 = GUICtrlCreateButton("退出安装(&X)", 210, 128, 90, 25)
GUISetState()
AdlibEnable("_timer", 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
Exit
Case $Button1
ExitLoop
EndSwitch
If $time <= 0 Then ExitLoop (Sleep(1000))
WEnd
main()
Exit
Func _timer()
$time -= 1
GUICtrlSetData($Label1, $time & "秒后将安装拖拉机,请选择!")
GUICtrlSetData($Progress1, ($timez - $time) / $timez * 100)
If $time <= 0 Then Return (GUICtrlSetData($Label1, "现在开始安装拖拉机 ")) & (AdlibDisable())
EndFunc ;==>_timer
Func main()
run("C:\拖拉机\拖拉机.EXE")
EndFunc ;==>main
修改得人性化了点,另外倒计时时间只需修改前面的 Dim $timez = 20 ,20秒改成其它值即可,其余处均不用调整。 |