简体   繁体   English

在游戏中按Enter聊天时如何关闭自动热键脚本?

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

I've written an autohotkey for Path of Exile (a game I'm playing) to press 5 buttons at once when I press single key (my spacebar). 我为流亡之路(我正在玩的游戏)编写了一个自动热键,当我按下单键(我的空格键)时可以同时按下5个按钮。 Currently, when I press the space bar, autohotkey also presses q, e, w, Space, and Z. (all 5) 当前,当我按空格键时,自动热键也按q,e,w,Space和Z。(全部5个)

However, when I'm chatting and press Spacebar, I get "qew z" entered into my chat. 但是,当我聊天并按空格键时,我在聊天中输入了“ qew z”。 This is super annoying, so I created a fix: "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." 这太烦人了,所以我创建了一个修复程序:“当我按下键盘上的Enter键时,关闭自动热键脚本,然后再次按下Enter时,将其重新打开。” (most games use the enter key to begin chatting) This worked, but after some time my script would become out of sync with the game. (大多数游戏使用Enter键开始聊天)。此方法有效,但是一段时间后,我的脚本将与游戏不同步。 It would be on when I am chatting, disrupting my chat, and then turn off when I'm done chatting. 当我聊天时,它会打开,打乱我的聊天,然后当我完成聊天时,它会关闭。

I discovered that this problem was sometimes a result of me pressing my shift or control and Enter at the same time. 我发现这个问题有时是由于我同时按下我的shift或control和Enter所导致的。 This opens chat, but doesn't pause the script. 这将打开聊天,但不会暂停脚本。 To fix this, I added a ^ and + in front of my enter scripts, but it still is finding ways to get out of sync!!!! 为了解决这个问题,我在输入脚本之前添加了^和+,但是它仍在寻找不同步的方法!!!!

Note: #Ifwinactive, Path of Exile is at the top to prevent this script from triggering when I don't have path of exile open. 注意:#Ifwinactive,流放路径位于顶部,以防止当我没有打开流放路径时触发此脚本。 That works perfectly (I think). 那很好(我认为)。

Please check my code below. 请在下面检查我的代码。 I have two questions: 我有两个问题:

  1. What is causing my script to get out of sync with the chat in the game? 是什么导致我的脚本与游戏中的聊天不同步?

  2. What is the best fix for my issue so that the script does not run when I have chat open, and always runs again when I'm finished chatting? 什么是对我的问题的最佳解决方案,以使脚本在打开聊天功能时不会运行,而在聊天结束后始终会再次运行?

Thanks in advance! 提前致谢!

#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

Wildcard * asterisk is what you wanted. 通配符*星号是您想要的。 It works by allowing the hotkey to trigger even if any combination of keys being held down. 通过允许热键触发,即使按住任意组合键也可以工作。 No need to repeat code, a blank hotkey above another will trigger the one below. 无需重复代码,另一个上方的空白热键将触发下面的一个。 Again, no reason to have all those keys typed out like you did. 同样,没有理由像您一样键入所有这些键。 Having them laid out inline works and is tidy. 让他们布置内联作品并且整洁。

Try: 尝试:

SendMode Input 

#Ifwinactive, Path of Exile

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

*~Enter::Suspend

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM