找回密码
 加入
搜索
查看: 1711|回复: 2

[系统综合] 等待某键的输入,如果指定时间内没有输入则运行一个程序

[复制链接]
发表于 2011-5-21 17:44:56 | 显示全部楼层 |阅读模式
如题:比如等待ESC键的输入,如果5分钟之内没有输入,则运行cmd.exe
知道用_IsPressed  可要在指定时间内没输入按键就不知道怎么搞了!高手们指点下下了呵呵
发表于 2011-5-21 19:47:54 | 显示全部楼层
本帖最后由 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)  

评分

参与人数 1金钱 +10 收起 理由
3mile + 10 学习了

查看全部评分

发表于 2011-5-21 22:09:25 | 显示全部楼层
试下另类的办法.
$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金钱 +10 收起 理由
tryhi + 10 同学习

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 05:46 , Processed in 0.086253 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表