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
  • Guests
  • Last active:
  • Joined: --
Vote-------- and just to be sure I'll quote Mr Horse: "No, sir I don't like it"

emmanuel d
  • Members
  • 519 posts
  • Last active: Jul 15 2017 12:04 PM
  • Joined: 29 Jan 2009
instead of:
i:=0 ; you dont need this line

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

Spam:

   Click

   Send a

   return

i use:
F7::SetTimer, F8, % (i:=!i) ? "100" : "Off" ; Press F7 to do the action repeatedly or to turn the repead off

F8::Send,{Click}a                           ; Pres F8 to do the action once
same result, exept i can still triger it once at the time.

Stopwatch emdkplayer
the code i post falls under the: WTFYW-WTFPL license

http://www.ahkscript.org/ the new forum


emmanuel d
  • Members
  • 519 posts
  • Last active: Jul 15 2017 12:04 PM
  • Joined: 29 Jan 2009

Hi there, thanks for the scripts, but can you make a code where you press ctrl and then whenever your hold down left button you rapid fire (1 per 30 milliseconds until you press ctrl again (ctrl is a toggle). I'm not really a coder and i'm a bit lazy so,

Thanks alot!

~ctrl::Toggle := !Toggle
~lbutton::
    If Toggle
		while GetKeyState("LButton","P")
			Send a
	returna
happy testing
you might want to add sleep,30 ore something

Stopwatch emdkplayer
the code i post falls under the: WTFYW-WTFPL license

http://www.ahkscript.org/ the new forum


CoreTwo
  • Members
  • 33 posts
  • Last active: Dec 29 2014 03:06 PM
  • Joined: 16 Oct 2007
It would really awesome if you could comment the scripts in the first post.

For example, in The Toggle, it starts with F8, sends an A and also a click.
Why the click?

The click caused a runaway condition which was a bit difficult to break from. I was able to break using task manager.

Anyway, I wanted a key to toggle when pressed, so pressing once would keep it down, and pressing again would stop pressing down - the purpose to always-run in Diablo II.

I figured it out and posted here:
http://www.autohotke...p=523325#523325

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

Why the click?

So that the area which you can edit is more recognizable.

  • Guests
  • Last active:
  • Joined: --
hello, i'm trying to work a custom autofire (with several time interval to choose from), based on the hold down type, which worked pretty fine at first.

but, while modifying it, i encountered a problem : it doesn't stop even when releasing the key.
since i don't know precisely what caused this (i think it was when i started to try using Input to choose the interval from a pool), i simply decided to start over from scratch.

so now, here is my new base script, which still has the same problem:
EnableAutoFire = 0

~WheelDown::
KeyWait, WheelDown, D
If EnableAutoFire = 0
	EnableAutoFire = 1
else
	EnableAutoFire = 0
return

~$LButton::
While (GetKeyState ("LButton", "P") && EnableAutoFire) {
	Click
	Sleep 180
}
return

here is what it should do:
1) enabling / disabling autofire with mouse wheel down
2) repeatedly send a click event as long as autofire is on and the left mouse button is pressed

1) works just fine
2) doesn't work. it starts sending clicks when the left button is pressed, but doesn't stop when the button is released.
using the mouse wheel down stop the firing just fine though. this behaviour is the same in the game, in notepad++, firefox or just any software in Windows

apparently, the problem comes from the GetKeyState ("LButton", "P") which doesn't return the right value.
in fact, adding MsgBox % GetKeyState ("LButton", "P") in the loop will pop up a message box saying LButton instead of 1 or 0 whether the button is still pressed or not.


any idea?

i already tried reinstalling autohotkey, didn't solve anything.

  • Guests
  • Last active:
  • Joined: --

apparently, the problem comes from the GetKeyState ("LButton", "P")

ok, my bad.
bad habits getting the worst of me, i've put an extra space between the function name and its arguments for better readability.
how come i notice this just now?
sorry.

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
I suggest altering the code for "The Toggle" in your original post. As it is:
toggle = 0
#MaxThreadsPerHotkey 2

F8::
    Toggle := !Toggle
     While Toggle{
        Click
        Send a
        [color=#FF0000]sleep 100[/color]
    }
return
it will not behave in a desirable fashion when it's hotkey is held longer than Window's repeat delay. You can eliminate this issue by changing the Sleep time from 100 to 1.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
The sleep time is intentionally 100 - that means 10 clicks and A's per second.

Would KeyWait work?

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011
The problem is not affected by the presence or absence of KeyWait. It arises (as Leef_me explained) because hotkeys are being pressed faster (via Windows' key repeat) than the hotkey code is processing them. Sleeping 100ms slows processing to the point that this situation occurs.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
In that case, the only solutions are to either use the SetTimer toggle method instead, or to press the key for a period of time shorter than the key-repeat wait time. I'll update the OP.

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011

In that case, the only solutions are to either use the SetTimer toggle method instead, or to press the key for a period of time shorter than the key-repeat wait time.

Another solution worked for me; did you try it?

toggle = 0
#MaxThreadsPerHotkey 2

F8::
    Toggle := !Toggle
     While Toggle{
        Click
        Send a
        [color=#FF0000]sleep 1[/color]
    }
return

I'll update the OP.

I'm looking forward to that. :)

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

Another solution worked for me; did you try it?

The sleep time is intentionally 100 - that means 10 clicks and A's per second.

There should be another solution though: using e.g. F8 Up:: instead of F8::

LazyMan
  • Members
  • 587 posts
  • Last active: Oct 21 2014 05:13 PM
  • Joined: 17 Feb 2011

There should be another solution though: using e.g. F8 Up:: instead of F8::

Yes--that prevents the problem from occurring, but it also requires both the press and release of the hotkey, which may be less desirable to someone looking to use automation to provide faster key input.

The sleep time is intentionally 100 - that means 10 clicks and A's per second.

If I wanted faster input, I would be more interested in "as fast as possible" than the arbitrary and relatively slow repeat rate of 10 keys per second. I think you could increase your already significant :D contribution with this thread by providing examples that approach maximum performance. (I hope to find such examples here instead of in someone else's "Definitive Autofire: Maximum Speed" thread. :p)

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
That is a good idea; I'll see what I can do when I have the time. IIRC, SendPlay, {LButton 2000} was as fast as clicks got (unless mouse_event exceeded it?)