找回密码
 加入
搜索
查看: 1463|回复: 3

[AU3基础] 长按键..

  [复制链接]
发表于 2011-3-10 17:24:58 | 显示全部楼层 |阅读模式
怎样实现对一个键(如[U])的长按(不是send的ALT&CTRL等)
另外_Ispressed函数能检测该键是否被长按中吗?谢谢
发表于 2011-3-10 19:16:19 | 显示全部楼层
send 一个键down就是对其长按
_Ispressed函数只能检测某键是否被按下,只用它不用测出时间长短的
发表于 2011-3-10 22:42:04 | 显示全部楼层
这要看多久时间算长按了。
#include <Misc.au3>

Global $time = 0
HotKeySet("{ESC}", "quit")

While 1
        If _IsPressed(55) = 1 Then
                While 1
                        If _IsPressed(55) <> 1 Then
                                $time = 0
                                ExitLoop
                        EndIf
                        If $time = 3 Then
                                ToolTip("")
                                MsgBox(0, 0,"U键长按了3秒")
                                ExitLoop
                        EndIf
                        Sleep(1000)
                        $time += 1
                        ToolTip("U 键按了 "& $time &" 秒,按ESC键退出")
                WEnd
        EndIf
        ToolTip("长按 U 键测试,按ESC键退出")
WEnd

Func quit()
        Exit
EndFunc
发表于 2011-3-17 11:55:48 | 显示全部楼层
thanks!!! good example.....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 10:43 , Processed in 0.080420 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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