autoclicker

Ask gaming related questions
TrulyZaraki
Posts: 1
Joined: 28 Mar 2023, 20:58

autoclicker

Post by TrulyZaraki » 28 Mar 2023, 21:01

I need a hotkey that gets 14-15 cps on right click but i click q to activate it and q to turn it off

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: autoclicker

Post by mikeyww » 28 Mar 2023, 21:59

Welcome to this AutoHotkey forum!

Code: Select all

; This is the third autoclicker ever made; all royalties to mikeyww, please
#Requires AutoHotkey v2.0
cps := 14
on  := False

q:: {
 Global on := !on
 SoundBeep 1000 + 500 * on
}

#HotIf on
RButton:: {
 start := A_TickCount, cliks := 0
 While GetKeyState(ThisHotkey, 'P') {
  Click
  Sleep start - A_TickCount + 1000 * ++cliks / cps
  ToolTip 'CPS = ' Round(1000 * cliks / (A_TickCount - start))
 }
 ToolTip
}
#HotIf

User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: autoclicker

Post by WalkerOfTheDay » 29 Mar 2023, 05:14

mikeyww wrote:
28 Mar 2023, 21:59
Welcome to this AutoHotkey forum!

Code: Select all

; This is the third autoclicker ever made; all royalties to mikeyww, please
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :clap: :clap:

Stealth7
Posts: 19
Joined: 12 Nov 2023, 17:21

Re: autoclicker

Post by Stealth7 » 12 Nov 2023, 17:37

mikeyww wrote:
28 Mar 2023, 21:59
Welcome to this AutoHotkey forum!

Code: Select all

; This is the third autoclicker ever made; all royalties to mikeyww, please
#Requires AutoHotkey v2.0
cps := Random(8, 12)
on  := False

q:: {
 Global on := !on
 SoundBeep 1000 + 500 * on
}

#HotIf on
RButton:: {
 start := A_TickCount, cliks := 0
 While GetKeyState(ThisHotkey, 'P') {
  Click
  Sleep start - A_TickCount + 1000 * ++cliks / cps
  ToolTip 'CPS = ' Round(1000 * cliks / (A_TickCount - start))
 }
 ToolTip
}
#HotIf
I found this interesting so i tried to randomise it aswell. However it doesn't randomise instead it uses the intented min value as CPS, so (8 in this case). Any solutions to this problem? Thanks in advance.


[Mod edit: Removed the code from the quoted section because it’s not what mikeyww actually posted since you modified it.]

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

Re: autoclicker

Post by boiler » 12 Nov 2023, 17:47

Stealth7 wrote: I found this interesting so i tried to randomise it aswell. However it doesn't randomise instead it uses the intented min value as CPS, so (8 in this case).
No, actually, it doesn’t. Unless you think it should be random every time you press the hotkey as opposed to every time you run the script. Then you would need to put the part where it chooses the random value inside the hotkey function.

Stealth7
Posts: 19
Joined: 12 Nov 2023, 17:21

Re: autoclicker

Post by Stealth7 » 12 Nov 2023, 19:31

boiler wrote:
12 Nov 2023, 17:47
Stealth7 wrote: I found this interesting so i tried to randomise it aswell. However it doesn't randomise instead it uses the intented min value as CPS, so (8 in this case).
No, actually, it doesn’t. Unless you think it should be random every time you press the hotkey as opposed to every time you run the script. Then you would need to put the part where it chooses the random value inside the hotkey function.
Thanks for the quick reply! I tried this;

Code: Select all

#Requires AutoHotkey v2.0
on  := False

q:: {
 Global on := !on
 SoundBeep 1000 + 500 * on
}

#HotIf on
RButton:: {
 start := A_TickCount, cliks := 0
 While GetKeyState(ThisHotkey, 'P') {
  Click
  Sleep start - A_TickCount + 1000 * ++cliks / Random(8, 12)
  ToolTip 'CPS = ' Round(1000 * cliks / (A_TickCount - start))
 }
 ToolTip
}
#HotIf
and

Code: Select all

; This is the third autoclicker ever made; all royalties to mikeyww, please
#Requires AutoHotkey v2.0
on  := False
cps := 8
cps2 := 10

q:: {
 Global on := !on
 SoundBeep 1000 + 500 * on
}

#HotIf on
Xbutton2:: {
 start := A_TickCount, cliks := 0
 While GetKeyState(ThisHotkey, 'P') {
  Click
  Sleep start - A_TickCount + 1000 * ++cliks / Random(cps, cps2)
  ToolTip 'CPS = ' Round(1000 * cliks / (A_TickCount - start))
 }
 ToolTip
}
#HotIf
Both seem to work but in a very weird way.. They spam hard then rests for a long period and then spams again.. Very inconsistent. However that may be because of the tickcounts?

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

Re: autoclicker

Post by boiler » 13 Nov 2023, 09:47

Nominally, the Sleep delay would simply be based on the value of CPS, but including A_TickCount looks like it is meant to account for the fact that Sleep delays aren't very accurate so it adjusts based on actual performance to that point. @mikeyww might be in a better position to see how your modifications may impact his original code.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: autoclicker

Post by mikeyww » 13 Nov 2023, 12:35

I tried to randomise it
This does not actually explain anything. It is unclear what should be randomized, and when.

The current script does already provide somewhat random sleep. You can check it to see what the sleep times are.

Code: Select all

; This is the third autoclicker ever made; all royalties to mikeyww, please
#Requires AutoHotkey v2.0
cps := 14
on  := False

q:: {
 Global on := !on
 SoundBeep 1000 + 500 * on
}

#HotIf on
RButton:: {
 start := A_TickCount, cliks := 0, tip := ''
 While GetKeyState(ThisHotkey, 'P') {
  Click
  Sleep wait := Round(start - A_TickCount + 1000 * ++cliks / cps)
  ToolTip tip .= wait '`n'
 }
 MsgBox 'CPS = ' Round(1000 * cliks / (A_TickCount - start))
}
#HotIf
If you want a random CPS with every iteration (which probably does not make a lot of sense), you have written that script, and noted that the sleep times will vary more because you are changing the target CPS. Thus, if the first CPS was 10 and you then move to 8 CPS (slower), the wait time needs to be longer and so will be adjusted accordingly. It is basically like what would happen if you are driving your car, and every second decide that you want to travel at a new random speed. You would have to accelerate or brake suddenly every second.

Kunkunca
Posts: 1
Joined: 13 Nov 2023, 12:32

Re: autoclicker

Post by Kunkunca » 13 Nov 2023, 12:39

Dear Mikeyww!
Please send me a private message! I need your help.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: autoclicker

Post by mikeyww » 13 Nov 2023, 12:46

Welcome to this AutoHotkey forum! Feel free to send a message when you wish. Kunkunca, as a new user, you probably need to wait for moderator approval.

Stealth7
Posts: 19
Joined: 12 Nov 2023, 17:21

Re: autoclicker

Post by Stealth7 » 13 Nov 2023, 13:07

boiler wrote:
13 Nov 2023, 09:47
Nominally, the Sleep delay would simply be based on the value of CPS, but including A_TickCount looks like it is meant to account for the fact that Sleep delays aren't very accurate so it adjusts based on actual performance to that point. @mikeyww might be in a better position to see how your modifications may impact his original code.
Thank you for the help!
If you want a random CPS with every iteration (which probably does not make a lot of sense)
I tried to make it more "human", which results in different CPS. For example when i personally do a CPS test i get between 7-9 CPS but whilst testing it can go down to 6 and then i click faster and it goes to 9, but then i get tired and it goes back down.. and so on. My take was that i compared it to an ahk script that i wrote for v1, which does the exact same but it has a more consistent "randomised" clicking. Anyway it was just for fun, since i have not yet gone over to v2. Thank you for the help a nice code!

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: autoclicker

Post by mikeyww » 13 Nov 2023, 13:48

If you do not need something "precise", you could simplify and just add a random sleep between consecutive clicks.

Code: Select all

#Requires AutoHotkey v2.0

RButton:: {
 While GetKeyState(ThisHotkey, 'P')
  Click(), Sleep(Random(15, 100))
}

Stealth7
Posts: 19
Joined: 12 Nov 2023, 17:21

Re: autoclicker

Post by Stealth7 » 13 Nov 2023, 15:01

mikeyww wrote:
13 Nov 2023, 13:48
If you do not need something "precise", you could simplify and just add a random sleep between consecutive clicks.

Code: Select all

#Requires AutoHotkey v2.0

RButton:: {
 While GetKeyState(ThisHotkey, 'P')
  Click(), Sleep(Random(15, 100))
}
Exactly here was my v1 take on that! Thanks again!

Code: Select all

Click() {
		Send {Click Left down}
		Send {Click Left up}
		random, time, 25, 80
	        Sleep, time
	}
Return

Post Reply

Return to “Gaming”