Autofire and toggle

Put simple Tips and Tricks that are not entire Tutorials in this forum
Geff T
Posts: 6
Joined: 07 May 2016, 15:16

Re: Autofire and toggle

09 May 2016, 18:25

tidbit wrote:Welcome to ahk, Geff T :)
ty

i have had to give in and ask a Q here https://autohotkey.com/boards/viewtopic ... 827#p85827but i wont go to OT
User avatar
evilC
Posts: 4780
Joined: 27 Feb 2014, 12:30

Re: Autofire and toggle

30 Jun 2016, 05:30

Please can we remove the GetKeyState technique for detecting release of a key? IMHO it is bad advice (Only works with one key) and is inefficient (Potentially introduces up to 10ms lag if you use a Sleep 10)

See here: https://autohotkey.com/boards/viewtopic.php?f=7&t=19745
wuuii

Re: Autofire and toggle

05 Mar 2017, 15:01

ok but how do i change the hotkey
User avatar
tidbit
Posts: 1178
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Autofire and toggle

05 Mar 2017, 16:22

please read before asking.
Helpful links:
1. Don't know how to use these? READ THIS: https://autohotkey.com/docs/Tutorial.htm
2. AHK not working in your game/program? READ THIS: https://autohotkey.com/boards/viewtopic.php?f=7&t=11084
3. List of keys to use as HOTKEYS (the line with "::"): https://autohotkey.com/docs/KeyList.htm
...
and also a link explaining.
as well as a tutorial teaching you the very basics.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
landfillbaby
Posts: 3
Joined: 27 Jan 2018, 18:56
GitHub: landfillbaby

Re: Autofire and toggle

27 Jan 2018, 19:01

Code: Select all

*Space::
Send {Space}
Sleep 250
Return
works for me (holding space presses it exactly 4 times per second), no need for a loop, i guess my keyboard works weird?
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

Re: Autofire and toggle

27 Jan 2018, 19:07

landfillbaby wrote:

Code: Select all

*Space::
Send {Space}
Sleep 250
Return
works for me (holding space presses it exactly 4 times per second), no need for a loop, i guess my keyboard works weird?

could it be that the hotkey and the key sent being the same key, that it's creating a loop on it's own
landfillbaby
Posts: 3
Joined: 27 Jan 2018, 18:56
GitHub: landfillbaby

Re: Autofire and toggle

28 Jan 2018, 02:06

GreatGazoo wrote:could it be that the hotkey and the key sent being the same key, that it's creating a loop on it's own
ok, i've just checked, it still works when the input isn't in the output

Code: Select all

Space::
Send hello
Sleep 250
Return
this would probably be a bad thing if i wasn't trying to make a loop anyway
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

Re: Autofire and toggle

28 Jan 2018, 02:50

landfillbaby wrote:
GreatGazoo wrote:could it be that the hotkey and the key sent being the same key, that it's creating a loop on it's own
ok, i've just checked, it still works when the input isn't in the output

Code: Select all

Space::
Send hello
Sleep 250
Return
this would probably be a bad thing if i wasn't trying to make a loop anyway


yeah i noticed that too with my random number generator, while holding control j it sends random number, enter, and it sends J's too

Code: Select all


^j::
    SoundBeep, 525, 100 
    Random, rand, 1, 10000
    send, %rand% {enter}
	return
	
landfillbaby
Posts: 3
Joined: 27 Jan 2018, 18:56
GitHub: landfillbaby

Re: Autofire and toggle

28 Jan 2018, 04:21

it turns out it's tied to the physical keyboard's auto-repeat feature, and is interrupted by other keypresses
i used this instead:

Code: Select all

SetKeyDelay -1
t=
Space Up::t=
Space::
t=1
While t {
Send % " "
Sleep 250
}
Return
it's basically just the toggle method but without the threading problem
User avatar
Delta Pythagorean
Posts: 567
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: Autofire and toggle

30 Jan 2018, 13:45

landfillbaby wrote:it turns out it's tied to the physical keyboard's auto-repeat feature, and is interrupted by other keypresses
i used this instead:

Code: Select all

SetKeyDelay -1
t=
Space Up::t=
Space::
t=1
While t {
	Send, % " "
	Sleep, 250
}
Return
it's basically just the toggle method but without the threading problem
If you want to use a spammer for a key, just use this. It's small, simple, and can be used anywhere in a script, not just a hotkey.

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.18362
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Delta#3324

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!
biti
Posts: 1
Joined: 25 May 2019, 14:34

Re: Autofire and toggle

25 May 2019, 15:05

hi guys i need a little script! very easy, activate/deactivate with F4, when i hold primary mousbutton pressed the mouse moves down with same speed without stop, and when i reallease the primarymousebutton it stops. can sombody help me pls?
rfxcasey
Posts: 2
Joined: 17 Jul 2020, 11:38

Re: Autofire and toggle

17 Jul 2020, 19:45

I know this thread is super old but as it's about a tool it seems like to place to request support for said tool. Have a weird problem, while running the test from this tool in game, the key inputs are indeed making it in game through several commands like Send, SendInput, SendEvnt and what have you. So I have a script that sends the same command that works in the test tool but it's not working in game. Autohotkey is set to run as Admin, I'm on the latest version, I've even tried compiling the script into a .exe file but it doesn't work in game. The script in question DOES work in a text window, toggle the key repeat on and on with the push of a button and that does indeed work in notepad. So what can the problem be, is it a problem with the window the script is focusing on? I've got the game in windowed mode, everything running as admin and just won't work. As said, keystrokes are making their way into the game via the test tool just not with my script.
LeafyKeaf
Posts: 1
Joined: 06 Aug 2020, 02:37

Re: Autofire and toggle

06 Aug 2020, 02:43

would there be a way to make it so it would click faster

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests