AutoHotkey 导致控制键卡住 [英] AutoHotkey causing control key to get stuck
问题描述
当我的控制键卡住时,我有几种情况,只有在我运行 AutoHotkey 时才会发生.这发生在多个不同的修饰键上,包括 control (^)、windows (#) 和 alt (!) 键.
I have several situations when my control key gets stuck, and it happens only when I have AutoHotkey running. This happens with multiple different modifier keys including the control (^), windows (#), and alt (!) keys.
类似的问题之前已经发过几次了:1,2,3.存在一些解决方案,这里建议的一个部分帮助了我(降低问题频率),但控制键偶尔卡住.我尝试过的事情包括 #InstallKeybdHook.
Similar problems have been posted several times before: 1, 2, 3. Some solutions exists, and the one suggested here partially helped me (decreased the frequency of the problem), but the control key still gets stuck occasionally. Things I have tried include #InstallKeybdHook.
我有两个问题:
- 是否可以防止这个问题?
- 是否有一种好方法可以让 AutoHotkey 在按键卡住时进行监控(例如,当按键被按住超过 10 秒时自动通知)并在发生时立即修复?
我已经尝试了上面建议的所有方法,并创建了自己的 StuckKeyUp 函数版本 (如此处建议的那样):
I have tried everything suggested above, and created my own version of a StuckKeyUp function (as suggested here):
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
}
推荐答案
其他调试方法你可以试试这个:
将此代码放在脚本中的特定位置(在发送控制键或计时器的热键定义内)
Put this code at specific positions in your script (within hotkey definitions that send the control key or in a timer)
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 {Blind}{Ctrl Up}
MsgBox,,, Ctrl released
KeyHistory
}
}
并查看 KeyHistory(关闭消息框后)在哪些情况下密钥会卡住.
and look in the KeyHistory (after closing the message box) in which situations the key gets stuck.
这篇关于AutoHotkey 导致控制键卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!