我的键盘存在问题,我在某些键上遇到键盘喋喋不休。我设法找到一个autohotkey脚本,有助于过滤键盘上的按键,但它实际上做的是重复发送相同的键,如果它被按下,这对我来说当我使用需要键的应用程序时出现问题坚持某些捷径(Maya,XSI等)
我尝试使用{blind}标志修改SendInput命令,并将'down'修饰符添加到%k_ThisHotkey%,但我无法让它正常工作。
(我为第一个sendinput添加了'down',并且为了检查密钥是否被按下而执行了GetKeyState,然后执行了一个条件,如果密钥被释放,SendInput将会执行。但是,这没有按预期工作,我没有想法。)
是否有人愿意就如何使用合适的去抖动脚本提供一些指示,同时允许按键也被按下?
谢谢!
; ---- setups
#UseHook On
;Capslock::LShift
; ---- initialize parameters
if (%0% > 0)
k_TimeThreshold = %1%
else
k_TimeThreshold = 40
;k_TimeThreshold = 1000 ; for debugging
; ---- initialize variables
k_LastHotkey = 0
k_LastTick := A_TickCount
; ---- Set all keys as hotkeys. See www.asciitable.com
k_ASCII = 33
Loop
{
Transform, k_char, Chr, %k_ASCII%
Hotkey, %k_char%, k_KeyPress
if ((k_char Not In +,^) AND (k_ASCII != 123 AND k_ASCII != 125))
{
Hotkey, +%k_char%, k_KeyPress ; shift
; Hotkey, ^%k_char%, k_KeyPress ; control
; Hotkey, !%k_char%, k_KeyPress ; alt
; Hotkey, #%k_char%, k_KeyPress ; win
}
if k_ASCII = 64
k_ASCII = 91
else if k_ASCII = 126
break
else
k_ASCII++
}
return
; ---- End of auto-execute section.
; ---- When a key is pressed by the user, send it forward only if it's not a "bounce"
; ---- A "bounce" is defined as: "key is same as last" AND "time since last key is very short"
Enter::
Space::
Tab::
Esc::
BS::
Del::
Ins::
Home::
End::
PgUp::
PgDn::
Up::
Down::
Left::
Right::
k_KeyPress:
{
k_ThisHotkey := A_ThisHotkey ; grab the current hotkey
k_ThisTick := A_TickCount ; grab the current tick
ElapsedTime := k_ThisTick - k_LastTick ; time since last hotkey (ticks)
if (ElapsedTime > k_TimeThreshold || k_ThisHotkey <> k_LastHotkey)
{
if k_ThisHotkey In !,#,^,+,{,},Enter,Space,Tab,Esc,BS,Del,Ins,Home,End,PgUp,PgDn,Up,Down,Left,Right
SendInput {%k_ThisHotkey%}
else
SendInput %k_ThisHotkey%
;SendInput %ElapsedTime% ; for debugging
}
k_LastHotkey := k_ThisHotkey ; store the current hotkey for next time
k_LastTick := k_ThisTick ; store the current tick for next time
}
return
; ---- other keys that could be filtered (but caused issues on some keyboards)
;LWin::
;RWin::
;LAlt::
;RAlt::
答案 0 :(得分:0)
这是一个想法。不确定它是否解决了您的问题。让我知道。我可以使用Shift来移动字母,弹跳键和普通按键之间有明显的区别。我只用 Shift , q 和 a 进行测试。
#SingleInstance Force
#installKeybdHook
#Persistent
Shift::
q::
a::
keywait, %A_ThisHotkey%
if (A_PriorHotkey = A_ThisHotkey AND A_TimeSincePriorHotkey < 900) ; bouncy key
{
Soundbeep, 500, 200
Return
}
Soundbeep, 2000, 200
return