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

如何在AHK脚本Sleep阶段禁用鼠标左键,执行完毕后恢复?

解决方案

可行,你可以通过AHK的Hotkey命令动态启用/禁用鼠标左键阻塞热键,修改后的脚本如下:

text = %1%

WinWaitActive, foobar, , 5
if ErrorLevel {
  Exit
}

; 启用鼠标左键阻塞热键
Hotkey, LButton, BlockLButton, On
Sleep, 300
; 禁用阻塞热键,恢复左键正常功能
Hotkey, LButton, Off

SendInput, %text%{Enter}
ExitApp

; 定义阻塞热键的处理逻辑
BlockLButton:
return

关键说明:

  • Hotkey, LButton, BlockLButton, On:将左键点击绑定到BlockLButton标签,启用后左键点击只会执行return,完全阻塞默认的左键功能
  • Hotkey, LButton, Off:解除左键的热键绑定,让左键恢复正常工作
  • 单独定义处理标签的方式比直接写LButton::return更灵活,方便精准控制热键的启用/禁用时机

内容的提问来源于stack exchange,提问作者Thomas W

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 00:02:04