1

我的键盘有问题,我在某些键上遇到了非常糟糕的键盘颤动。我设法找到了一个自动热键脚本,它有助于过滤键盘上的按键,但是它实际上所做的是在按住它时重复发送相同的键,当我使用需要键的应用程序时,这给我带来了问题按住某些快捷方式(Maya、XSI 等)

我尝试使用 {blind} 标志修改 SendInput 命令并将 'down' 修饰符添加到 %k_ThisHotkey%,但我永远无法让它正常工作。

(我为第一个 sendinput 添加了一个“down”,并执行了 GetKeyState 以检查键是否被按住,然后做了一个条件,如果键被释放,SendInput up 将执行。但是,这并没有按预期工作,我没有想法。)

有人愿意就我如何让一个适当的去抖动脚本工作,同时还允许按住键给出一些指示吗?

谢谢!

; ---- 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::
4

1 回答 1

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
于 2013-03-15T08:16:13.117 回答