|
贴上定时器程序片段:
大侠们帮我讲解下,$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword");创建自定义函数Timer的回调,API定时器函数SetTimer需要
为什么这里要设置4个回调参数,每个参数的作用是什么,实在搞不定,我还发现最后一个参数"dword"可以删除掉,程序也能运行.
还有在Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)里, $idEvent可以获取定时器ID,这是如何获取的,搞不懂.
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword");创建自定义函数Timer的回调,API定时器函数SetTimer需要
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer));1000毫秒执行一次
$Timer2DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 200, "ptr", DllCallbackGetPtr($Timer));200毫秒执行一次
$Timer3DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 2000, "ptr", DllCallbackGetPtr($Timer));2000毫秒执行一次
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
Switch $idEvent;根据定时器ID来进行操作
Case $TimerDLL[0]
GUICtrlSetData($Label1, @HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC);更新时间
Case $Timer2DLL[0]
$t2 += 1
GUICtrlSetData($Label2, $t2);更新+1
Case $Timer3DLL[0]
$t3 *= 2
GUICtrlSetData($Label3, $t3);更新2的自乘
EndSwitch
EndFunc |
|