Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

The definitive autofire thread!


  • Please log in to reply
130 replies to this topic
nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
keywords: rapidclick auctoclick fast toggle fire shoot rapid key press repeatedly press keys mouse spam key spam toggle key press autofire autopress rapidfire cycle COD MW2 MWF2 MW CSS CS:S Cheat macro hack The definitive autofire thread by nimda


At the bottom of this post you will find two ready-to-go autoclickers/RapidClickers!

This is the one size fits all autofire thread. Here, you will find many different ways to spam keys, repeat actions, etc. It aims to keep the scripts very short (enough to fit in a non scrolling code box) but at the same time be very clear. After the title of most is a one-line explanation of how to use it.

Most scripts will click, type 'a', and wait 1/10 of a second during its loop. You can replace this with your own code in any of the spots. Most scripts will use the F8 hotkey.

There are several types of loops that can be made:

The SetTimer: (Same as the simple pause, but allows other code to run)
SetTimer Click, 100

F8::Toggle := !Toggle

Click:
    If (!Toggle)
        Return
    Click
    Send a
return
The SetTimer (ternary version, by None, doesn't use resources when off):

i:=0 
F7::SetTimer, Spam, % (i:=!i) ? "100" : "Off" ; uses ternary

Spam: 
   Click
   Send a
return
If you find the ternary ( ? : ) operator difficult, check out the ternary guide by [VxE] or use the other SetTimer method.


The Toggle: (Press once to start, again to stop, etc like the simple pause)
Warning: If the hotkey used by the Toggle is input faster than the loop executes, the maximum number of simultaneous threads per hotkey can be exceeded, which leaves the execution "stuck" in a spamming state (reference Leef_me's explanation).
toggle = 0
#MaxThreadsPerHotkey 2

F8::
    Toggle := !Toggle
     While Toggle{
        Click
        Send a
        sleep 100
    }
return
The Self-Sender: (emulates auto-repeat) (hold down the key to do action)

$a::
 While GetKeyState("a","p"){
  Send a
  Sleep 100
 }
return
The Simple Pause: (Press F8 to toggle state i.e., once on, two off...)

Pause
Loop{
 Click
 Send a
 sleep 100
}
F8::Pause
The Hold-Down: (key retains functionality unless held down)

$a::
    KeyWait a, T0.5                 ; Wait 1/2 second for user to release "a" key
    If ErrorLevel                   ; Still held down
        While GetKeyState("a","p"){ ; While it is held down
            Click
            Send a
            Sleep 100
        }
    Else                            ; They let go in time
        Send a
return
 

The Cycle (cycles through a list of keys to send)
list=a,b,c,{enter},string{click} ; the list of keys and combos. comma separated.
stringsplit, list, list,`,
Counter = 0

$F8::                                ; press F8 to cycle through
  Counter := (Counter=list0) ? (1) : (Counter+1)
  send % list%counter%
return
If you find the ternary ( ? : ) operator difficult, check out the ternary guide by [VxE] or tidbit's ternary-free post down the page.


The Cycle-Hold-Down: (Cycles through the list while F8 is held)
list=a,b,c,{enter},string{click}    ; the list of keys and combos. comma separated. 
stringsplit, list, list,`,
Counter = 0

$F8::
    While GetKeyState("F8","P"){
        Counter := (Counter=list0) ? (1) : (Counter+1)
        Send % list%counter%
        Sleep 50
    }
return
 

And, by very popular request, two cut and paste (Voila! It works!) autoclickers: *
Hold Click to Rapid-Click:
~$LButton::
    While GetKeyState("LButton", "P"){
        Click
        Sleep 50  ;  milliseconds
    }
return
Hold F8 to Rapid-Click:

F8::
    While GetKeyState("F8", "P"){
        Click
        Sleep 50 ;  milliseconds
    }
return
*The toggle works well for this purpose as well

To have any key exit the loop, see this example.
 
 
 

It doesn't work in my game!

https://ahknet.autoh...faqbot/faq.html
http://www.autohotke...s/FAQ.htm#games

Here are some helpful links to get you started customizing these:
#MaxThreadsPerHotkey
Send
Click
KeyWait
GetKeyState
Loop (normal)
SetTimer

Edited by nimda, 06 August 2015 - 10:35 PM.
Removed broken color from the code boxes.


tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
great idea!
was going to suggest a few and then i decided to scroll the page down and was like 'oh, he has pretty much everything covered.'

good job :!:

maybe add some keywords to the first thread. to help searchers.

keywords: toggle cycle fire shoot rapid key press repeatedly press hotkeys keys mouse spam key cycle key cycler spam toggle key press autofire auto hotkey auto hotkeys autopress COD MW2 cycle MWF2 MW CSS CS:S Cheat macro hack I'm a noob and need to cheat, The definitive autofire thread by nimda

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Why thank you tidbit. I did try to make it live up to its title. If anyone has other ideas (that fit within a non-scrolling code box :) ) I'd be happy to add them to the first post. I'll add tags when I can post from my computer (my phone doesn't have cut & paste)

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
this has popped up a couple times.

The Cycler: (send a certain key on one press, then another on a different press.)
list=a,b,c,{enter},tidbit{enter}    ; the list of keys and combos. comma separated. 
stringsplit, list, list, `,         ; create the array.
return

$j::                                ; press J to cycle through the list
  counter+=1                        ; identify the next key index
  if (counter<=list0)               ; if we have not passed the end of the array...
    key:=list%counter%              ; ... assign the key to the appropriate index
  else {                            ; otherwise
    counter:=1                      ; set the counter to the first index
    key:=list%counter%              ; and assign key to the first key index
  }                                 ; 
  sendplay %key%                    ; finally we send the figgin' key!
  sleep, 50                         ; time in Milliseconds
return

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Related to cycling: Cycle()

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
tidbit, do you think I should use a ternary operator for that? (Readability vs conciseness)

Edit: I added it in ternary but cannot test right now. Please notify me if it's wrong! I also plan on having a cycle which runs continuously while held down. Might not code that for a few days (due to lack of testing) unless someone "donates" it.

*Edit: It is not wrong.
**Edit: the 'cycle hold down' has been thoroughly tested

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008

tidbit, do you think I should use a ternary operator for that? (Readability vs conciseness)

Edit: I added it in ternary but cannot test right now. Please notify me if it's wrong! I also plan on having a cycle which runs continuously while held down. Might not code that for a few days (due to lack of testing) unless someone "donates" it.

I was going to use a ternary, but couldn't figure it out. forgot i could use an expression in an expression (counter+1).

And yes, yours works. if we get complaints or many questions, just swap with mine. and well, mine is only a couple posts down. so it's not THAT hard to find if a noob (or non-noob) decides to read the thread.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009
I am not a gamer but this autoclick primer is quite educational! Thanks Nimda.

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

I am not a gamer but this autoclick primer is quite educational! Thanks Nimda.

You're very welcome! :)

Edit:
Due to the nearly 500 views and only 1 suggestion (which has been added), I assume that I got pretty much everything on the first try :D
I hope that people will link here instead of posting code, as everything here is tested, optimized (but not 'golfed'), and presents good coding practice

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
I got one. I see this a lot on the help forum. People want to spam 'skills'. It usually consists of pressing a set of keys at different intervals for each key.

F8::
Skills := "A=1000 K=4000", t:=!t
Loop, Parse, Skills, %A_Space%, `n`r
	SetTimer, % SubStr(A_LoopField,1,InStr(A_LoopField,"=")-1), % (t ? SubStr(A_LoopField,InStr(A_LoopField,"=")+1) : "off")
return

A:
K:
SendInput %A_ThisLabel%
return
Had to sacrafice a little readability for shortness. Mainily the SetTimer line...

Anyway if its up to par, add, modify, whatever. If it doesn't fit with the page, I wouldn't be offended :)

btw Nice job on the ones you posted! I can imagine redirecting people here all the time :D
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

I got one. I see this a lot on the help forum. People want to spam 'skills'. It usually consists of pressing a set of keys at different intervals for each key.
...

I'll add this one once I get it straightened out and possibly shortened. If you could please link me to a few help topics (don't worry, I'll search too :) Edit: all I got was this thread + 1001 ragnarok beggars), I could see what's really being asked. What is wanted the most? (More than one at a time? One key cycles through skills?)

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
ehh...I remember seeing it a lot but I can't find any examples. :?
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010
here is a similar post i made a while ago

<!-- m -->http://www.autohotke...pic.php?t=62385<!-- m -->

i think it helps people if they understand the script so they can change it rather than rely on someone to give them stuff.

maybe you should try add some explanation behind some of this stuff, perhaps using ; comments

cool post though, well presented

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

Thanks, I guess now I can refer to your explanation of toggles instead of posting my own here. Although, this has always bothered me:

Loop
{
GetKeyState, var, LButton, P ;Get the state of Lbutton
If var = U ;has it been released?
Break
}

is the same as
While GetKeyState("LButton", "P"){
}

Saves 4 lines of code per hotkey! Very important, my 15 hotkeys like this == 60 fewer lines of code == exactly 1 entire screenful of code on my system

Edit: and these annoy me too:
If (var <>0) && (var <>1)
var := 0
var := ((var+1) & 1)
; Or,
var := (var = 1) ? (0) : (1)
; Or,
If var = 1
var = 0
else
var = 1
because all those just do this:
var := !var


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Here are a few advanced pieces of code to study :)
Have fun figuring out what they do; if you want help just ask
If you want more like these, just ask:

#MaxThreadsPerHotkey 2
Index = 0
List = a,b,c
StringSplit, List, List,`,
return

F8::
   T := !T
   While (T){
      Index := Index >= List0 ? 1 : Index+1 ; Cycle the index
      Send % List%Index%
      Sleep 50 ; Milliseconds
   }
return

#MaxThreadsPerHotkey 3 ; The number of actions
index = 0

F8::
   Index := (Index >= 3 ? 1 : Index+1)
   While (Index <> 3){
      If ( Index ) = 1
         Send first{Space}
      Else If ( Index = 2 )
         Send Second{Space}
      Sleep 50
   }
return

list = a,b,c
StringSplit list, list,`,
index=1

F8::
   While GetKeyState("F8", "P"){
      Send % List%index%
      Sleep 50
   }
return

F8 up::index := Index >= List0 ? 1 : Index+1