回复 9# wingking84
用GUI和注册$WM_Keydown消息完美解决你的问题,请尝试一下代码:
Global Const $WM_KEYDOWN = 0x0101
Local $timer,$interval,$flag
$hwd = GUICreate("TEST",300,300)
GUIRegisterMsg($WM_KEYDOWN, "WM_KeyDown")
;$OkButton = GUICtrlCreateButton("ok",10,10,20,20)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
EndSwitch
WEnd
Func WM_KeyDown($HWnd,$iMsg,$wParam,$lParam)
Local $KeyNumber = BitAND($wParam,0xFF)
;MsgBox(0, "", "按键值是: " & $KeyNumber)
If $KeyNumber = 32 Then
If $flag = 0 Then
$timer = TimerInit()
$flag = 1
Else
$interval = TimerDiff($timer)
MsgBox(0,0,"两次空格键的时间间隔是:"& $interval)
$flag = 0
EndIf
EndIf
EndFunc
|