zjcly6 发表于 2011-3-10 17:24:58

长按键..

怎样实现对一个键(如)的长按(不是send的ALT&CTRL等)
另外_Ispressed函数能检测该键是否被长按中吗?谢谢

xyold1 发表于 2011-3-10 19:16:19

send 一个键down就是对其长按
_Ispressed函数只能检测某键是否被按下,只用它不用测出时间长短的

yhxhappy 发表于 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

hkc5599 发表于 2011-3-17 11:55:48

thanks!!! good example.....
页: [1]
查看完整版本: 长按键..