Page 1 of 1

Hotkey Interference

Posted: 27 Mar 2024, 01:45
by Pianist
Hi! I'm new to AHK. I have a script for The Long Dark game which includes 2 hotkeys E and R. E is to toggle the sprint and R is to toggle the radial menu. But when I press them together, they interfere with each other and I have to press them twice to activate each one. Is there a way to disable R when I press E and vice versa to prevent double pressing? Thanks a lot. Also, these are the scripts that I use:

Code: Select all

e::
KeyDown := !KeyDown
SendInput {lshift}
Sleep, 30
If KeyDown
	SendInput {lshift down}
Else
	SendInput {lshift up}
Return

r::
KeyDown := !KeyDown
SendInput {tab}
Sleep, 30
If KeyDown
	SendInput {tab down}
Else
	SendInput {tab up}
Return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

[Mod action: Moved topic from “Ask for Help (v2)” because this is v1 code and it is for a game. Please note the sub-forum to which your post has been moved, and post in the appropriate place next time.]

Re: Hotkey Interference

Posted: 28 Mar 2024, 02:56
by Pianist
I had another question, how can I cancel the script e:: that is for auto sprinting by pressing for example S (backward key) ?

Re: Hotkey Interference

Posted: 29 Mar 2024, 09:52
by tabr3
Without remake the script.
You can simply rename all instances of "keydown" to something like "keydown_e" and "keydown_r" within their respective threads.

Code: Select all

~*s::
keydown_e:="" ; or keydown without _e if you still not modify them...
if (GetKeyState("lshift", "P")) ; optional, incase you still need to run by yourself using lshift
return				       ; optional
SendInput {lshift up}
return
For another question. Untested :)

Re: Hotkey Interference

Posted: 29 Mar 2024, 15:21
by Pianist
Thank you very much my friend, This script works great. Can you find a solution to my first question?

Re: Hotkey Interference

Posted: 29 Mar 2024, 15:34
by Pianist
Although after pressing S key I still have to double press e key to activate auto sprint, which is very unnatural and annoying..

Re: Hotkey Interference

Posted: 29 Mar 2024, 21:22
by Pianist
You are a life saver :) I just removed optional lines and it solved all of my problems. God bless you my friend