我有几种情况会导致我的控制键卡住,并且只有当我运行 AutoHotkey 时才会发生这种情况。这种情况发生在多个不同的修饰键上,包括 control (^)、windows (#) 和 alt (!) 键。
类似的问题之前已经发过多次了:1 https://autohotkey.com/board/topic/121292-control-key-getting-stuck-after-script-runs/,
2 https://autohotkey.com/board/topic/3248-stuck-ctrl-key/page-2,
3 https://autohotkey.com/board/topic/98025-ctrl-key-stuck/。存在一些解决方案,并且这里建议的部分帮助了我 https://autohotkey.com/board/topic/88715-control-key-getting-stuck/(减少了问题发生的频率),但控制键仍然偶尔会卡住。我尝试过的事情包括#InstallKeybdHook https://www.autohotkey.com/docs/commands/_HotkeyModifierTimeout.htm.
我有两个问题:
- 有可能避免这个问题吗?
- 有没有一种好方法可以让 AutoHotkey 在按键卡住时进行监控(例如,当按键被按住超过 10 秒时自动通知)并在发生时立即修复?
我已经尝试了上面建议的所有内容,并创建了我自己的 StuckKeyUp 函数版本(如此处建议的) https://autohotkey.com/boards/viewtopic.php?t=19711:
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
}
除其他外调试方法 https://autohotkey.com/docs/Scripts.htm#debug你可以试试这个:
将此代码放在脚本中的特定位置(在发送控制键的热键定义内或在计时器中)
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(关闭消息框后)在哪些情况下按键会卡住。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)