Assist with AHK Script?

0

the below code is an AHK script that i have been using. It works very well. Essentially what it does is it pulls the mouse down for me, while im holding left control and the left mouse button.

The issue that i am having, is that i need the cursor to stay completely in the middle. The game that i play, makes it so that when you shoot (hold left mouse button) the gun will "sway" left and right. Sad to say, i have failed miserably at every attempt to incorporate this into my script below.

Can anyone please help?

#NoEnv
SendMode Input

~F6::Suspend
~End::ExitApp
~F5::Reload

LCtrl & ~LButton::
Loop
If GetKeyState("LButton", "LCtrl") {
Sleep, 6
moveAmount := (moveAmount = 2) ? 1 : 0
mouseXY(moveAmount,7.5)

}
else
break

Return



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

TheyCallMeChop

Posted 2017-03-27T15:21:51.763

Reputation: 11

Answers

0

This is now the third time I'm answer a question regarding to this exact script.

Probably, whoever it was that scripted the original, just copy/pasted parts from other scripts and sort of semi- got it to work.

It looks like

moveAmount := (moveAmount = 2) ? 1 : 0

is the attempt of doing something like that.

what it does is this:

if(moveAmount == 2) { moveAmount := 1 } else { moveAmount := 0 }

Since moveAmount is not set elsewhere, it can never be 2 therefore, it can never be 1, thus it will always be 0. hence; no horizontal movement.

if you want to alternate between looking to the right and left you could do something like this:

moveAmount := (moveAmount == 2 ? -2 : 2)

This would set it to 2 the first iteration, -2 the second, then 2 again the third, and so on.

Which would move it left, and then right, and then left etc

But I'm still getting a sense that moveAmount is meant to be declared in some part of the script that's not there anymore.

Maybe someone just gave up attempting to detect how much left or right the gun moved.

fisknils

Posted 2017-03-27T15:21:51.763

Reputation: 86