LZ 如果有简单源码例子应该早就解决了。
要做到LZ的要求实现的方法不少,这里写了个简单例子,给需要的朋友参考#include <Timers.au3>
Local $hGUI = GUICreate('_Timer_SetTimer 倒计时+任务例子', 350, 100)
Local $Label1 = GUICtrlCreateLabel('20秒倒计时中…', 8, 8, 340, 12)
Local $Label2 = GUICtrlCreateLabel('20', 120, 40, 100, 30, 0x01)
GUICtrlSetFont(-1, 20, 800, 0, '微软雅黑')
GUISetState()
Global $QS = 20, $Q = $QS, $iLast = 1
$iTimer = _Timer_SetTimer($hGUI, 1000, '_DJS')
While GUIGetMsg() + 3 <> 0
WEnd
_Timer_KillTimer($hGUI, $iTimer)
GUIDelete()
Func _DJS($1, $2, $3, $4)
#forceref $1, $2, $3, $4
$Q -= 1
If $Q = 0 Then
$Q = $QS
If $iLast Then AdlibRegister('_A', 10)
EndIf
GUICtrlSetData($Label2, $Q)
EndFunc ;==>_DJS
Func _A()
AdlibUnRegister()
$iLast = 0
GUICtrlSetData($Label1, '正在投票啥的… 如有超时则增加新一轮倒计时')
Sleep(Random(5000, 30000, 1)) ;模拟5S - 30S(超出单次倒计时范围)延时
$iLast = 1
GUICtrlSetData($Label1, '投票完毕,等待下一个倒计时完成…')
EndFunc ;==>_A
|