#include "DllCallBack.au3"
#Include <Date.au3>
#include <GuiConstants.au3>
GuiCreate("Timer", 124, 99)
$Label_1 = GuiCtrlCreateLabel("Time loading...", 10, 10, 140, 20)
$Label_2 = GuiCtrlCreateLabel("00", 10, 40, 70, 20)
$Label_3 = GuiCtrlCreateLabel("00", 10, 70, 80, 20)
Global $pTimerProc = _DllCallBack ("_TimerProc", "hwnd;uint;uint;dword")
Global $uiTimer = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", $pTimerProc)
Global $pTimerProc2 = _DllCallBack ("_TimerProc", "hwnd;uint;uint;dword")
Global $uiTimer2 = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 200, "ptr", $pTimerProc2)
Global $pTimerProc3 = _DllCallBack ("_TimerProc", "hwnd;uint;uint;dword")
Global $uiTimer3 = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 700, "ptr", $pTimerProc3)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer[0])
_DllCallBack_Free ($pTimerProc)
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer2[0])
_DllCallBack_Free ($pTimerProc2)
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer3[0])
_DllCallBack_Free ($pTimerProc3)
Exit
Case Else
;;;
EndSelect
WEnd
Exit
Func _TimerProc($hWnd, $uiMsg, $idEvent, $dwTime)
;$idEvent能分辨是哪个Timer控件调用了这个函数
;$dwTime表示已开机的时间
Switch $idEvent
Case $uiTimer[0]
GUICtrlSetData($Label_1,_Now ( ))
Case $uiTimer2[0]
GUICtrlSetData($Label_2,GUICtrlRead($Label_2)+1)
Case $uiTimer3[0]
GUICtrlSetData($Label_3,GUICtrlRead($Label_3)+1)
EndSwitch
EndFunc
最后,你可以使用KillTimer函数中止一个Timer控件,其用法在上面的例子里已经阐明。