2次按键的问题【已解决】
本帖最后由 austere 于 2014-9-7 00:28 编辑比如说按2次ctrl键运行msgbox窗口,具体怎么实现呢,求方法,能贴上代码最好! 三克油
实现的效果就像360搜索一样,按2下ctrl键 弹出搜索窗口,求解~ 仅供参考,代码好像不稳定。
#include <Misc.au3>
HotKeySet("{ESC}", "_exit")
Global $hDLL = DllOpen("user32.dll")
Local $count = 0
While 1
If _IsPressed("11", $hDLL) Then ;CTRL键按下?
$count += 1
If $count >= 2 Then
MsgBox(0, 0, "2次Ctrl了")
$count = 0
EndIf
EndIf
Sleep(250)
WEnd
Func _exit()
DllClose($hDLL)
Exit
EndFunc ;==>_exit 回复 2# xms77
感谢您的回复,论坛搜索了下找到了另一种解决方法,简单修改了一下你的例子,附上代码:#include <Misc.au3>
HotKeySet("{ESC}", "_exit")
Global $lastIsRight = False
Global $lastTime
While 1
If _IsPressed("11") = True Then chuangkou()
WEnd
Func chuangkou()
While _IsPressed("11")
Sleep(50)
WEnd
$nowTime = DllCall("kernel32.dll", "int", "GetTickCount")
If $lastIsRight = False Then
$lastTime = DllCall("kernel32.dll", "int", "GetTickCount");
$lastIsRight = True;
Else
Local $nowTime = DllCall("kernel32.dll", "int", "GetTickCount")
If ($nowTime - $lastTime) < 550 Then
$lastIsRight = False;
Else
$lastTime = $nowTime;
EndIf
EndIf
If $lastIsRight = False Then MsgBox(0, 0, "按了2次CTRL")
EndFunc ;==>chuangkou
Func _exit()
Exit
EndFunc ;==>_exit
页:
[1]