AutoHotkey 导致控制键卡住

Ste*_*emo 7 autohotkey modifier-key windows-10

当我的控制键卡住时,我有几种情况,只有在我运行 AutoHotkey 时才会发生。这发生在多个不同的修饰键上,包括 control (^)、windows (#) 和 alt (!) 键。

类似的问题之前已经发布过多次: 1 , 2 , 3。存在一些解决方案,此处建议的解决方案部分帮助了我(降低了问题的频率),但控制键偶尔仍会卡住。我尝试过的事情包括#InstallKeybdHook

我有两个问题:

  1. 是否有可能防止这个问题?
  2. 当按键被卡住时,是否有一个让 AutoHotkey 监控的好方法(例如,当按键被按住超过 10 秒时自动通知)并在它发生时立即修复它?

我已经尝试了上面建议的所有内容,并创建了我自己的 StuckKeyUp 函数版本(如此处所建议的)

StuckKeyUp(){
sleep 300 
send {<# up} 
send {># up} 
send {# up} 
send {+ up} 
send {<+ up} 
send {! up} 
send {<! up} 
send {>! up} 
send {^<^^>! up} 
send {^<^>! up} 
send {^ up} 
send {Ctrl down} 
send {Ctrl up}

Send {§ up}         
Send {Shift Up}
Send {LShift Up}
Send {RShift Up}
Send {Alt Up}
Send {LAlt Up}
Send {RAlt Up}
Send {Control Up}
Send {LControl Up}  
Send {<^ down}      
Send {<^ Up}        ; solves some issues, but not all
Send {>^ down}      
Send {>^ Up}        
Send {RControl Up}
Send {LControl Up}
Send {LWin Up}
Send {RWin Up}
sleep 100 
; reload, ; Avoid - Reloading AutoHotkey File causes functions depending on this function to break
return 
}
Run Code Online (Sandbox Code Playgroud)

use*_*297 4

正如其他答案和我原来的答案中所建议的:

您可以尝试其他调试方法

  • #HotkeyModifierTimeout影响热键修饰符的行为:Ctrl、Alt、Win 和 Shift。

  • 通过添加行#InstallKeybdHook安装键盘挂钩。

  • 使用SendInput方法。

  • 将此代码放在脚本中的特定位置(在发送控制键的热键定义内或在计时器中),并在 KeyHistory 中(关闭消息框后)查看按键卡住的情况:

If GetKeyState("Ctrl")           ; If the OS believes the key to be in (logical state),
{
    If !GetKeyState("Ctrl","P")  ; but the user isn't physically holding it down (physical state)
    {
        Send {Ctrl Up}
        MsgBox,,, Ctrl released
        KeyHistory
    }
}
Run Code Online (Sandbox Code Playgroud)

要覆盖您可以使用的所有修饰键

#Requires AutoHotkey v1.1

#NoEnv
#InstallKeybdHook
SendMode Input

Keys := "LControl,RControl,LAlt,RAlt,LWin,RWin,LShift,RShift"
SetTimer, ReleaseKeys, 500 

; ....

            RETURN   ; === end of auto-execute section ===


; Your hotkeys here

; ....

ReleaseKeys:
    Loop, parse, Keys, `,
    {
        If GetKeyState(A_LoopField)           ; If the OS believes the key to be in (logical state)
        {
            If !GetKeyState(A_LoopField,"P")  ; but the user isn't physically holding it down (physical state)
            {
                Send {%A_LoopField% Up}
                MsgBox,,, %A_LoopField% released
                KeyHistory
            }
        }
    }
Return
Run Code Online (Sandbox Code Playgroud)