等待某键的输入,如果指定时间内没有输入则运行一个程序
如题:比如等待ESC键的输入,如果5分钟之内没有输入,则运行cmd.exe知道用_IsPressed可要在指定时间内没输入按键就不知道怎么搞了!高手们指点下下了呵呵 本帖最后由 tryhi 于 2011-5-21 20:34 编辑
回复 1# shounei
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$time = TimerInit()
While 1
Sleep ( 100 )
If TimerDiff($time) > 5*60*1000 Then
MsgBox(0,0,"同学,还不按ESC?")
Exitloop
EndIf
If _IsPressed("1B", $dll) Then
$time = TimerInit()
EndIf
WEnd
DllClose($dll) 试下另类的办法.
$time=TimerInit()
HotKeySet("{Enter}", "test")
HotKeySet("{Esc}", "_Exit")
AdlibRegister("press_key",30*1000)
While 1
Sleep(100)
ToolTip(int(TimerDiff($time)/1000)&"秒")
WEnd
Func press_key()
AdlibUnRegister("press_key")
msgbox(0,0,"Time Over")
_run()
$time=TimerInit()
AdlibRegister("press_key",30*1000)
EndFunc
Func test()
AdlibUnRegister("press_key")
msgbox(0,0,"Pressed 'Enter' Key")
_run()
$time=TimerInit()
AdlibRegister("press_key",30*1000)
EndFunc
Func _run()
;这里是超时需要执行的代码
EndFunc
Func _Exit()
AdlibUnRegister("press_key")
Exit
EndFunc
页:
[1]