当我在游戏中按回车聊天时,如何关闭自动热键脚本?

How do I turn off an autohotkey script when I press enter to chat in games?

我已经为流亡之路(我正在玩的游戏)编写了一个自动热键,当我按下一个键(我的 space 栏)时可以同时按下 5 个按钮。目前,当我按下 space 栏时,autohotkey 还会按下 q、e、w、Space 和 Z。(全部 5)

但是,当我聊天并按 Space 栏时,我会 "qew z" 进入我的聊天。这太烦人了,所以我创建了一个修复程序:"Toggle the autohotkey script off when I press the Enter key on my keyboard and then toggle it back on when I press Enter again."(大多数游戏使用回车键开始聊天)这很有效,但一段时间后我的脚本会与游戏不同步。聊天的时候就开,打断我的聊天,聊完了就关

我发现这个问题有时是因为我同时按下了 shift 或 control 和 Enter。这会打开聊天,但不会暂停脚本。为了解决这个问题,我在我的输入脚本前面添加了一个 ^ 和 +,但它仍然在寻找不同步的方法!!!!

注意:#Ifwinactive,流放之路位于顶部,以防止在我没有打开流放之路时触发此脚本。这非常有效(我认为)。

请检查下面我的代码。我有两个问题:

  1. 是什么导致我的脚本与游戏中的聊天不同步?

  2. 我的问题最好的解决方法是什么,这样当我打开聊天时脚本不会 运行,当我结束聊天时总是再次 运行s ?

提前致谢!

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Ifwinactive, Path of Exile

Space::
Send {q}
Send {e}
Send {w}
Send {Space}
Send {z}
Return

^Space::
Send {q}
Send {e}
Send {w}
Send {Space}
Send {z}
Return

~Enter:: 
 Suspend Permit
 Suspend
 Return

~!Enter:: 
 Suspend Permit
 Suspend
 Return

~^Enter:: 
 Suspend Permit
 Suspend
 Return

~+Enter::
 Suspend Permit
 Suspend
 Return

通配符 * 星号是您想要的。它的工作原理是允许热键触发,即使按下任何组合键也是如此。无需重复代码,另一个上方的空白热键将触发下方的热键。同样,没有理由像您一样输入所有这些键。将它们布置成内联作品并且很整洁。

尝试:

SendMode Input 

#Ifwinactive, Path of Exile

^Space::
$Space::Send, qew{Space}z

*~Enter::Suspend