Help alternate send with keystroke then {Enter}

Ask gaming related questions (AHK v1.1 and older)
quentinw88
Posts: 2
Joined: 18 May 2022, 16:07

Help alternate send with keystroke then {Enter}

Post by quentinw88 » 18 May 2022, 16:21

There is a game where you type the direction you want your character to move. I'm running into two issues which I've tried troubleshooting but can't seem to figure it and need the help of the community.

Issues
1. I've tried applying {Enter} in multiple locations of the script but continue to receive errors. There is a spam filter in the game so alternating between CAPS helps bypass it. I currently need to press the Enter key each time to submit the text but it would be more efficient if the action of pressing Enter could be integrated into the script.

2. Whenever "S" is pressed, it alternates between sending "onRightup" and "Donup". Not sure why that is and I can't see anything in the script that would cause it to type that.

Thanks very much for your help in advance.

Code: Select all

W::
toggle := !toggle
send, % toggle ? "up" : "UP"
return

A::
toggle := !toggle
send, % toggle ? "left" : "LEFT"
return

D::
toggle := !toggle
send, % toggle ? "right" : "RIGHT"
return

S::
toggle := !toggle
send, % toggle ? "down" : "DOWN"
return

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Help alternate send with keystroke then {Enter}

Post by mikeyww » 18 May 2022, 20:01

Welcome to this AutoHotkey forum!

Use the dollar prefix to avoid triggering a loop or other hotkey.

Code: Select all

$w::Send % ((on := !on) ? "up"    : "UP"   ) "`n"
a:: Send % ((on := !on) ? "left"  : "LEFT" ) "`n"
s:: Send % ((on := !on) ? "down"  : "DOWN" ) "`n"
$d::Send % ((on := !on) ? "right" : "RIGHT") "`n"

quentinw88
Posts: 2
Joined: 18 May 2022, 16:07

Re: Help alternate send with keystroke then {Enter}

Post by quentinw88 » 19 May 2022, 00:19

@mikeyww Thank you so much! that works exactly as imagined. Will definitely learn to use the $ prefix in the future! thanks for the help and for sharing that!

Post Reply

Return to “Gaming Help (v1)”