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

如何为AutoHotkey脚本添加基于鼠标状态的切换功能?

实现方法

可以通过AutoHotkey的GetKeyState()函数检测鼠标右键(鼠标2键)的实时按压状态,结合条件判断来切换发送内容。

修改后的完整脚本
f::
Send {p down}  
Sleep 200  
Send {p up}
sleep, 899
; 检测鼠标右键状态,切换发送内容
if GetKeyState("RButton", "P")
    Send, 8
else
    Send, 7
return

2::
Send {o down}  
Sleep 200  
Send {o up}
; 第一处发送逻辑
if GetKeyState("RButton", "P")
    Send, 8
else
    Send, 7
sleep, 899
; 第二处发送逻辑
if GetKeyState("RButton", "P")
    Send, 8
else
    Send, 7
return

capslock::suspend
return
关键说明
  • GetKeyState("RButton", "P"):RButton是鼠标右键的键名,P参数表示检测物理按键的实时状态,不受软件模拟按键的干扰,确保判断的是用户实际按住鼠标右键的动作。
  • 把原脚本中所有需要切换的Send, 7替换成上述条件判断块,即可实现“按住鼠标右键时发送8,否则发送7”的需求。

内容的提问来源于stack exchange,提问作者Emperror Lich

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 13:45:32