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). Currently, when I press the space bar, autohotkey also presses q, e, w, Space, and Z. (all 5)
However, when I'm chatting and press Spacebar, I get "qew z" entered into my chat. 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." (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. 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. 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. That works perfectly (I think).
Please check my code below. I have two questions:
What is causing my script to get out of sync with the chat in the game?
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
Esc
or some other key, so AHK won't know it should be active again; etc. You might want to switch to a more reliable solution. Here are some suggestions: 1) Create a unique hotkey (like^Space
or maybe a quick "double space") for either the normal space or your special functionality. 2) Define "reactivation" hotkey that always unsuspends the script when it's out of sync. – MCL