Same codes but different triggers in one place.

Ask gaming related questions (AHK v1.1 and older)
Pacifista
Posts: 46
Joined: 17 Jan 2022, 16:17

Same codes but different triggers in one place.

Post by Pacifista » 16 Apr 2023, 13:19

Hello, i have been using this for my character to look left, dash and look back at the original position.
Then created another one and both of them are working with separate keys but when i paste them in one file
cant get them to work without conflict.

both keys are working and doing only 1 way dash. Chatgpt wrote something but it's variants also didnt work.

There might be too many unnecessary pasting here too and a few lines could get the job done.

Code: Select all

LOOP_TIMES := 1
SPEED := 1064 ; Set It To -300 To Go To The Left

c::
Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Sleep, 10
   Send !{f}
   sleep, 10
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
return

LOOP_TIMES := 1
SPEED := -1064 ; Set It To -300 To Go To The Left

z::
Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Sleep, 10
   Send !{f}
   sleep, 10
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
   Loop, %LOOP_TIMES%
   DllCall("mouse_event", uint, 1, int, SPEED, int, 0, uint, 0, int, 0)
return

[Mod actions: Moved thread from main (v2) section because this is v1 code. Added [code][/code] tags. Use them yourself when posting code.]

User avatar
boiler
Posts: 17397
Joined: 21 Dec 2014, 02:44

Re: Same codes but different triggers in one place.

Post by boiler » 16 Apr 2023, 13:30

These lines would never execute:

Code: Select all

LOOP_TIMES := 1
SPEED := -1064 ; Set It To -300 To Go To The Left
They’re stuck in between hotkeys. When looking at the structure of your script, ask yourself: How would AHK know that those lines are supposed to execute when you press z when they appear before the z hoteky? When would they ever execute? The two lines at the top execute when the script starts because they are in the auto-execute section, and never again.

It looks like you are expecting everything that is indented under the first loop to be grouped under that loop. Indenting doesn’t group lines of code in AHK. Code blocks are defined by braces { }.

Btw, don’t use ChatGPT for AHK. It produces terrible code.

Post Reply

Return to “Gaming Help (v1)”