Help with my AutoClicker Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
HKUK01
Posts: 7
Joined: 18 Jun 2018, 12:48

Help with my AutoClicker

18 Jun 2018, 12:53

Hey, I'm a beginner and I've been looking for a code which can click on a random position within a range of set coordinates and sleep for a random amount of time within a range of time. The code I made only clicks on a specific coordinate and sleeps for a specific time.

f1::
MouseClick , Left , 10 , 19
sleep 600
MouseClick , Left , 565 , 180
sleep 600
MouseClick , Left , 289 , 199
sleep 600

Any help will be greatly appreciated.
User avatar
DyaTactic
Posts: 183
Joined: 04 Apr 2017, 05:52

Re: Help with my AutoClicker

18 Jun 2018, 14:48

Use the Random function to generate a random number.

Code: Select all

Random, OutputVar, Min, Max
Let me know if you have any more questions.
swagfag
Posts: 2981
Joined: 11 Jan 2017, 17:59

Re: Help with my AutoClicker  Topic is solved

18 Jun 2018, 14:56

wrap random in a function, then define another function for clicking, sleep accepts expressions, so it can be used as is, in conjunction with your wrapped random function

Code: Select all

q::
	randClick(1, 1, 20, 20)
	Sleep rand(300, 1000)	
	randClick(1, 1, 20, 20)
Return

rand(min, max) {
	Random, rand, min, max
	return rand
}

randClick(x1, y1, x2, y2) {
	x := rand(x1, x2)
	y := rand(y1, y2)
	Click %x%, %y%
}
HKUK01
Posts: 7
Joined: 18 Jun 2018, 12:48

Re: Help with my AutoClicker

18 Jun 2018, 15:15

swagfag wrote:wrap random in a function, then define another function for clicking, sleep accepts expressions, so it can be used as is, in conjunction with your wrapped random function

Code: Select all

q::
	randClick(1, 1, 20, 20)
	Sleep rand(300, 1000)	
	randClick(1, 1, 20, 20)
Return

rand(min, max) {
	Random, rand, min, max
	return rand
}

randClick(x1, y1, x2, y2) {
	x := rand(x1, x2)
	y := rand(y1, y2)
	Click %x%, %y%
}
Hey, thanks for replying, I used your code below and it works great but I don't know what I'm doing wrong because on 'click 3' which I've added it doesn't seem to click on the right co-ordinate. Also how would I loop this entire code for a specific number of times? Thanks.

Code: Select all

q::
	randClick(0, 0, 80, 80) ;click1
	Sleep rand(300, 1000)	
	randClick(680, 1040, 730, 1060) ;click2
	Sleep rand(300, 1000)
	randClick(890, 100, 900, 110) ;click3
Return

rand(min, max) {
	Random, rand, min, max
	return rand
}

randClick(x1, y1, x2, y2) {
	x := rand(x1, x2)
	y := rand(y1, y2)
	Click %x%, %y%
}
HKUK01
Posts: 7
Joined: 18 Jun 2018, 12:48

Re: Help with my AutoClicker

18 Jun 2018, 15:34

DyaTactic wrote:Use the Random function to generate a random number.

Code: Select all

Random, OutputVar, Min, Max
Let me know if you have any more questions.
Hey, thanks for replying, I've implemented the random function into the code but was wondering how I would loop this entire code below for a specific number of times. Also 'click 3' doesn't seem to click on to the correct co-ordinate. Thanks.

Code: Select all

q::
	randClick(0, 0, 80, 80) ;click1
	Sleep rand(300, 1000)	
	randClick(680, 1040, 730, 1060) ;click2
	Sleep rand(300, 1000)
	randClick(890, 100, 900, 110) ;click3
Return

rand(min, max) {
	Random, rand, min, max
	return rand
}

randClick(x1, y1, x2, y2) {
	x := rand(x1, x2)
	y := rand(y1, y2)
	Click %x%, %y%
}
swagfag
Posts: 2981
Joined: 11 Jan 2017, 17:59

Re: Help with my AutoClicker

18 Jun 2018, 15:39

check the CoordMode function and select a mode accordingly.
User avatar
DyaTactic
Posts: 183
Joined: 04 Apr 2017, 05:52

Re: Help with my AutoClicker

18 Jun 2018, 15:40

Looping like this?

Code: Select all

q::
	Loop, 3	; Repeat 3 times.
	{
		randClick(0, 0, 80, 80) ;click1
		Sleep rand(300, 1000)	
		randClick(680, 1040, 730, 1060) ;click2
		Sleep rand(300, 1000)
		randClick(890, 100, 900, 110) ;click3
	}
Return
HKUK01
Posts: 7
Joined: 18 Jun 2018, 12:48

Re: Help with my AutoClicker

18 Jun 2018, 15:53

DyaTactic wrote:Looping like this?

Code: Select all

q::
	Loop, 3	; Repeat 3 times.
	{
		randClick(0, 0, 80, 80) ;click1
		Sleep rand(300, 1000)	
		randClick(680, 1040, 730, 1060) ;click2
		Sleep rand(300, 1000)
		randClick(890, 100, 900, 110) ;click3
	}
Return
Yup that works fine and I figured out the problem with click 3 thanks a lot for the help.
User avatar
DyaTactic
Posts: 183
Joined: 04 Apr 2017, 05:52

Re: Help with my AutoClicker

18 Jun 2018, 16:18

You're most welcome

Return to “Ask For Help”

Who is online

Users browsing this forum: BreezeB, euras, Google [Bot], hotkeyguy, hymal7, marcefw and 216 guests