You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AutoHotkey v2:按住Shift键时XButton2代码块无法执行的修复需求

解决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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 20:25:58