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
x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010

Although, this has always bothered me.....


Of course using while-loops and var = !var is easier, However people dont understand them by looking at them, in that post my focus was teaching people how to understand the code rather than being the most efficient.

If i were to write that post again i would change it considerably, but for now ill let it sink into the sand

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
I submit a "hit any key to break" candidate for inclusion in your original post.

BliND123
  • Members
  • 19 posts
  • Last active: May 06 2011 05:02 PM
  • Joined: 02 Jul 2007
Nice thread, really helps a lot! :D

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
@Lazyman - That's a bit bulky...
I think using A_TimeIdlePhysical would be much shorter...
However, I'll link you for now.

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
I generally try to use formatting to make code easier to understand, but to address your desire to have examples "that fit within a non-scrolling code box", I trimmed a few lines for you :p :

; Hit any key to break

1::
   SendPlay 1
   SetTimer Spam1, 30
   Input AnyKey, L1, {LWin}{RWin}{AppsKey}{LShift}{RShift}{LControl}{RControl}{LAlt}{RAlt}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Insert}{Delete}{Home}{End}{PgUp}{PgDn}{Space}{Tab}{Enter}{Escape}{Backspace}{CapsLock}{NumLock}{ScrollLock}{PrintScreen}{Pause}{Numpad0}{Numpad1}{Numpad2}{Numpad3}{Numpad4}{Numpad5}{Numpad6}{Numpad7}{Numpad8}{Numpad9}{NumpadIns}{NumpadEnd}{NumpadDown}{NumpadPgDn}{NumpadLeft}{NumpadClear}{NumpadRight}{NumpadHome}{NumpadUp}{NumpadPgUp}{NumpadDot}{NumpadDel}{NumpadDiv}{NumpadMult}{NumpadSub}{NumpadAdd}{NumpadEnter}
   SetTimer Spam1, Off
Return

Spam1:
   SendPlay 1
Return
I'm curious about how you would implement this using A_TimeIdlePhysical; please share your idea.

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

$1 up::
   Send 1
   SetTimer, Spam, 30
   sleep 25
   While A_TimeIdlePhysical > 20
      Sleep 5 ; Continue
   SetTimer, Spam, Off
return

Spam:
   Send 1
return
It's not as 'perfect' as the Input solution, but it looks cleaner. I must admit to being guilty of making this up on the spot :D

This has exactly one problem: If it were to also turn off by pressing '1', this would need to use the Hotkey command, and then wouldn't fit in this tiny code box

It could be golfed further by using a loop and a setTimer ternary, instead of settimers outside a while.

Seems the Input command is still the best, but I do like this way

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
First, thank you for sharing your idea. :)

... and then wouldn't fit in this tiny code box

Do you realize that whether or not code fits into a non-scrolling code box is dependent upon such things as choice of browser, screen resolution, browser window width, browser font size, browser zoom level, etc.?

I must admit to being guilty of making this up on the spot

With leniency based on your confession ;) , your code has two race conditions:
[*:11jpkcyq] Most important: Your script may not be scheduled to run in time to catch a key press during its tiny window. (This just happened to me as I entered "1" to create this list while having your script running; I had several letters of the alphabet scattered among the many 1's which poured into this post.)
[*:11jpkcyq] "1" can sometimes stop the spamming, depending on whether the timer is set or turned off first.

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
the box starts to scroll after a certain number of lines, not number of pixels.
you can have 15 lines before it decides to scroll. if you go over 15 lines, only 14 show.
it should be hard-coded into the site, not the browser.

Am I right?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

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


LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
tidbit, to see an example demonstrating my point, watch the number of lines change in the code box in my post above as you decrease the width of your browser window. Using Firefox 4.0.1, the behavior of the code box is dependent upon whether or not a scroll bar is initially present. If the scroll bar is present on the box when you open the page, it appears whenever the width is small enough to require it. If, on the other hand, a scroll bar is not initially present, the code box will resize as you reduce the window width to accomodate the lines as necessary (I can get 23 for that post).

Polarbear
  • Members
  • 5 posts
  • Last active: May 17 2011 08:37 PM
  • Joined: 15 May 2011

And, by very popular request, two cut and paste (Voila! It works!) autoclickers: *
Hold Click to Rapid-Click: (umm...)

~[color=orange]$[/color][color=darkred]LButton[/color]::
    While GetKeyState("[color=darkred]LButton[/color]","P")[color=red]{[/color]
        Click
        Sleep 50  ;  milliseconds
    [color=red]}[/color]
return

Hold F8 to Rapid-Click: (Title doesn't explain itself?)
[color=darkred]F8[/color]::
    While GetKeyState("[color=darkred]F8[/color]","P")[color=red]{[/color]
        Click
        Sleep 50 ;  milliseconds
    [color=red]}[/color]
return
*The toggle works well for this purpose as well


First one gives me the error:

Posted Image

Second script gives me this error:


Posted Image

:S I just want a script that would spam mouse one as I have one for spamming the space key for using to constantly jump ingame:

*~$Space:: 
Sleep 150
Loop 
{ 
    GetKeyState, SpaceState, Space, P 
    If SpaceState = U 
        break  
    Sleep 1 
    Send, {Blind}{Space} 
} 
Return


nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Polarbear:
:!: :!:
Important: update your AHK installation. All the code in that post is thouroughly tested on the latest Basic and v1.1
If you update, there will be no problems.
While is a command added a 'while' back :p

  • Guests
  • Last active:
  • Joined: --

Polarbear:
:!: :!:
Important: update your AHK installation. All the code in that post is thouroughly tested on the latest Basic and v1.1
If you update, there will be no problems.
While is a command added a 'while' back :p


Thanks, you just solved all my problems :) However.. my friend can click faster than me still, with his G15 keyboard script:


if (event == "G_PRESSED" and arg == 1 and GetMKeyState() == 3) then
ClearLCD ()
OutputLCDMessage("Starting 200 clicks")
for i=1,200 do PressAndReleaseMouseButton(1) end
OutputLCDMessage("Done") 
end

Is there any ahk equivalent? I took the 0ms out from script but the script above still clicks faster

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
There are many ways to speed up ahk.
There's SetBatchLines -1
There's SetMouseDelay and SetKeyDelay.
There's SendMode Input and Play
You can use Process, Priority,, High
You can turn off ListLines
You can just plain remove all Sleeps in the code.

HTH

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
Polarbear":2ci0r0dv">

However.. my friend can click faster than me still

How much time does it take for your friend's script to execute?

On my system:

F12::
   StartTime := A_TickCount
   Loop 200
      Click
   ElapsedTime := A_TickCount - StartTime
   MsgBox %ElapsedTime%
Return
reports 6250 milliseconds, but

F12::
   StartTime := A_TickCount
   Loop 200
      SendPlay {Click}
   ElapsedTime := A_TickCount - StartTime
   MsgBox %ElapsedTime%
Return
reports 3125 milliseconds.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
LazyMan: I think your code is deceiving.
You forgot one, causing the source of the problem to be obscured. The problem arises not from the commands but from SendMode.

Try the click example again with Sendmodes Input and play.

Also, try "click 200" and "Send {lbutton 200}"

lets see how fast we can make this :)