Help me fix my first script? (AHK)

Ask gaming related questions
miscfit
Posts: 3
Joined: 16 Jul 2020, 05:45

Help me fix my first script? (AHK)

16 Jul 2020, 06:11

Hello~
I just started trying to learn AHK 2days ago, and I'm working on this no-recoil script and I have finally made it almost exactly what I want, but there's a few issues that I can't seem to figure out.

What I need help with on this script: the MAIN problem currently is that the cursor won't stop pulling down after I release the Left Mouse Button. I only want it to START working when I HOLD the right mouse button+left mouse button at the same time, and have it STOP when I release the left, then start again from the beginning if I hold Left click again.

Right now if I click once with the left button, it goes through the whole plot on it's own, and I cant stop it until it's done. +everytime I click again it restarts the plot :/
Also I want a toggle button to turn the script on/off, so that I can aim normally without it when I need to.

I have the mouse values set up to counter the recoil of the gun I want to use it with almost perfectly, so hopefully they won't have to change.. I've spent nearly 16hours on this thing today and I'm stumped right now hehe

Apologies if this post has typos, or is generally incoherent, it's nearly 5AM here :x

here's the script so far

Code: Select all

     #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%
     
    F1::
    Loop
    {
    CapsLock::Suspend
     
    ~LButton::
    if (GetKeyState("LButton", "P"))

     if state = U                  ;-- The key has been released, so break out of the loop.
            break


SendMode Input


mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-2,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-2,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-2,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(-1,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10
mouseXY(0,1)
sleep 10

return

}


mouseXY(x,y)
{
DllCall("mouse_event",int,1,int,x,int,y,uint,0,uint,0)
}

Thanks in advance if you help! I really appreciate it
Rohwedder
Posts: 3385
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help me fix my first script? (AHK)

17 Jul 2020, 03:07

Hallo,
try:

Code: Select all

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
Seq0 := ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-1,,,,-1,,,,-1,,,
,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-2,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,
,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-2,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,
,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-2,,,,-1,,,,-1,,,
,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,,-1,,,End"
Sequence := [], No := 0
Loop, Parse, Seq0, CSV
	Sequence[A_Index] := A_LoopField
Return
RButton & LButton::SetTimer, Timer, 10
RButton & LButton Up::
SetTimer, Timer, Off
No := 0
Return
Timer:
IF Sequence[++No] = "End"
	No := 1
IF !x := Sequence[No] ;empty
	x := 0
mouseXY(X,1)
Return
CapsLock:: ;toggle button to turn the script on/off
Suspend
Pause,,1
KeyWait, CapsLock
Return
mouseXY(x,y)
{
	DllCall("mouse_event",int,1,int,x,int,y,uint,0,uint,0)
}

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 10 guests