Autoclicker: Need help on User input & loop command

Ask gaming related questions (AHK v1.1 and older)
yaoz889
Posts: 9
Joined: 24 Mar 2016, 16:38

Autoclicker: Need help on User input & loop command

24 Mar 2016, 16:51

Alright everyone, I just need some help on finishing the autoclicker.

Here is my code so far:

toggle = 0
#MaxThreadsPerHotkey 2
F12::
Toggle := !Toggle
While Toggle{
Random, rand2, 2843, 3045
Random, rand1, 53, 113
Random, xpos1, 505, 529
Random, ypos1, 568, 578
Random, xpos2, 505, 529
Random, ypos2, 568, 578

Click %xpos1% %ypos1%
sleep, rand1
Click %xpos2% %ypos2%
sleep, rand2

}
return

Basically, an autoclicker that will click at a specific spot with a 2 delay time at random mouse positions (within reason).

Now, I want to be able use a iteration loop, where the user inputs a value, say 4, and the program goes through it 4 times.

I've tried:
F12::
Loop, 6
{
Random, rand2, 2843, 3045
Random, rand1, 53, 113
Random, xpos1, 505, 529
Random, ypos1, 568, 578
Random, xpos2, 505, 529
Random, ypos2, 568, 578

Click %xpos1% %ypos1%
sleep, rand1
Click %xpos2% %ypos2%
sleep, rand2
return
}

but somehow, it just clicks three times and cancels......

Also, I looked on the help section and found only: InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default], but it only gives a string, but I want a value, so the loop can use the input to loop the correct number of times.

I am really stuck, so any help would be appreciated....
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Autoclicker: Need help on User input & loop command

24 Mar 2016, 18:50

yaoz889 wrote:Alright everyone, I just need some help on finishing the autoclicker.

Here is my code so far:
Spoiler
Basically, an autoclicker that will click at a specific spot with a 2 delay time at random mouse positions (within reason).

Now, I want to be able use a iteration loop, where the user inputs a value, say 4, and the program goes through it 4 times.

I've tried:
Spoiler
but somehow, it just clicks three times and cancels......

Also, I looked on the help section and found only: InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default], but it only gives a string, but I want a value, so the loop can use the input to loop the correct number of times.

I am really stuck, so any help would be appreciated....

Hi try this :

Code: Select all

F12::
InputBox, val, LOOP TIMES, Enter Number:,,200,120,,,,,6
Loop, %val%
{
Random, rand1, 53, 113
sleep, rand1

Random, xpos1, 505, 529
Random, ypos1, 568, 578
Click %xpos1%, %ypos1%

Random, xpos2, 505, 529
Random, ypos2, 568, 578
Click %xpos2%, %ypos2%

Random, rand2, 2843, 3045
sleep, rand2

}
return
:wave: There is always more than one way to solve a problem. ;)
User avatar
Spawnova
Posts: 555
Joined: 08 Jul 2015, 00:12
Contact:

Re: Autoclicker: Need help on User input & loop command

26 Mar 2016, 05:58

Here's another approach

Code: Select all

#persistent
iterations := 1 ;default
return

f11::
inputbox,iterations,Iterations,input the amount of times to click below
tooltip,Iterations set to %iterations%
settimer,tooltipoff,1000
return

tooltipoff:
tooltip
return

F12::
loop % iterations {
Click(505,568,529,578) ;x,y,x2,y2
sleep % Random(2843,3045)
}
return

f8::exitapp
f9::reload

Click(x,y,x2=false,y2=false) {
	if (x2 and y2) {
		x := Random(x,x2)
		y := Random(y,y2)
	}
	Click,%x%,%y%,down
	sleep % Random(53,77)
	Click,up
}

Random(min,max) {
	random,v,%min%,%max%
	return v
}
I've included 2 functions which simplifies the process making it much better on the eyes. =P
yaoz889
Posts: 9
Joined: 24 Mar 2016, 16:38

Re: Autoclicker: Need help on User input & loop command

26 Mar 2016, 15:40

YoucefHam wrote:
yaoz889 wrote:Alright everyone, I just need some help on finishing the autoclicker.

Here is my code so far:
Spoiler
Basically, an autoclicker that will click at a specific spot with a 2 delay time at random mouse positions (within reason).

Now, I want to be able use a iteration loop, where the user inputs a value, say 4, and the program goes through it 4 times.

I've tried:
Spoiler
but somehow, it just clicks three times and cancels......

Also, I looked on the help section and found only: InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default], but it only gives a string, but I want a value, so the loop can use the input to loop the correct number of times.

I am really stuck, so any help would be appreciated....

Hi try this :

Code: Select all

F12::
InputBox, val, LOOP TIMES, Enter Number:,,200,120,,,,,6
Loop, %val%
{
Random, rand1, 53, 113
sleep, rand1

Random, xpos1, 505, 529
Random, ypos1, 568, 578
Click %xpos1%, %ypos1%

Random, xpos2, 505, 529
Random, ypos2, 568, 578
Click %xpos2%, %ypos2%

Random, rand2, 2843, 3045
sleep, rand2

}
return
Thanks a lot
yaoz889
Posts: 9
Joined: 24 Mar 2016, 16:38

Re: Autoclicker: Need help on User input & loop command

26 Mar 2016, 15:40

Spawnova wrote:Here's another approach

Code: Select all

#persistent
iterations := 1 ;default
return

f11::
inputbox,iterations,Iterations,input the amount of times to click below
tooltip,Iterations set to %iterations%
settimer,tooltipoff,1000
return

tooltipoff:
tooltip
return

F12::
loop % iterations {
Click(505,568,529,578) ;x,y,x2,y2
sleep % Random(2843,3045)
}
return

f8::exitapp
f9::reload

Click(x,y,x2=false,y2=false) {
	if (x2 and y2) {
		x := Random(x,x2)
		y := Random(y,y2)
	}
	Click,%x%,%y%,down
	sleep % Random(53,77)
	Click,up
}

Random(min,max) {
	random,v,%min%,%max%
	return v
}
I've included 2 functions which simplifies the process making it much better on the eyes. =P
thanks a lot, just what I needed

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 104 guests