AutoHotkey v2:按住Shift键时XButton2代码块无法执行的修复需求
这问题本质是AutoHotkey默认会把带修饰键(比如Shift)的按键组合当成独立的热键,所以按住Shift时按XButton2,脚本识别不出这是你定义的~XButton2热键。
只需要给XButton2的热键加个*前缀,就能让它无视任何修饰键的状态,不管Shift、Ctrl、Alt有没有按住,按XButton2都能触发对应的代码。
修改后的完整脚本:
#SingleInstance Force ~x:: { Send "{2 down}" Sleep 50 ;sleep Send "{2 up}" Sleep 50 Send '{Alt}' Sleep 300 MouseClick "Right" Send '{Alt}' return } ; XButton2 these are some extra button with my mouse ; XButton1 *~XButton2:: { Send "{6 down}" Sleep 50 Send "{6 up}" Sleep 50 MouseClick "Right" }
修改说明
- 新增的
*前缀:让热键忽略所有修饰键(Shift、Ctrl、Alt等)的状态,确保XButton2无论在什么按键组合下都能触发。 - 保留
~前缀:保证XButton2本身的原生功能不会被脚本屏蔽,如果你鼠标的XButton2原本有自带功能,还能正常使用。
内容的提问来源于stack exchange,提问作者user24974510
相关产品推荐
相关产品推荐

