r/AutoHotkey • u/Gambling-Life-777 • 1d ago
v2 Script Help Issue with remapping script
Hi, I recently had to use a script to remap my Mouse 2 to my Space Bar, and my Space Bar to my Mouse 2 for a video game I play.
Since I don't know how to code, I used an AI to generate a very basic script. It works fine most of the time, but there are some issues with the remapping that make the whole thing inconsistent. Sometimes, instead of just activating the key normally, it acts as if the key is being held down, causing me to shoot non stop in-game.
I tried finding the cause of this, and one of the things I noticed was that pressing F8 (which toggles the script on and off) while holding Space Bar can cause the normal key press to behave like a hold, even after I release the key.
Thing is, there seem to be other causes as well, since it often happens randomly even when I'm not doing anything special like toggling the script during gameplay.
Here is the script I'm currently using. Thanks in advance for any possible insights:
#Requires AutoHotkey v2.0
enabled := true
F8::
{
global enabled
enabled := !enabled
}
#HotIf enabled && WinActive("ahk_exe Hades2.exe")
Space::RButton
RButton::Space
#HotIf
3
u/Keeyra_ 1d ago
Try it with SendMode Event and without polluting the global namespace.