Rapid fire toggle script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Thelegend27

Rapid fire toggle script

18 May 2018, 19:34

Hello,

I am relatively new to AHK and have almost no idea what I am doing, but I do love to play fps games and am looking for a script with f8 as the toggle key. I would like the script to be a rapid fire click, however only when I am holding the mouse (I do not want an autoclicker). I have done the tutorials and research of my own and came up with this script (see below). The rapid fire part of the script works, however I can't figure out how to toggle the rapid fire on and off using the f8 key. If anyone can help it would be greatly appreciated, thanks.

Code: Select all

#MaxThreadsPerHotkey 2

F8::
  if  (Toggle := !Toggle) {
/::suspend
LButton::
Loop
{
SetMouseDelay 20
Click
If (GetKeyState("LButton","P")=0)
Break
}
return
}
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script

19 May 2018, 01:30

Hallo,
try:

Code: Select all

HotKey, LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
F8::Hotkey, LButton, % (Toggle := !Toggle) ? "On" : "Off"
LButton:: ;Fast Fire part
	SetMouseDelay 20
	While GetKeyState("LButton","P")
		Click
Return
Dragoo
Posts: 3
Joined: 08 Aug 2020, 19:57

Re: Rapid fire toggle script

08 Aug 2020, 20:17

This script works, but when I hold shift key before press LBUTTON the macro does not work. If anyone can help to fix it would be greatly appreciated. Thanks.

Code: Select all

F8::suspend
if (Toggle = !Toggle) {
    
    LButton::
        Loop
        {
            SetMouseDelay 68
            Click
            If (GetKeyState("LButton","P")=0)
                Break
        }
    return
}
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script

09 Aug 2020, 00:35

Then perhaps:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton, % (Toggle := !Toggle) ? "On" : "Off"
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
frostwalter
Posts: 3
Joined: 25 Aug 2023, 01:30

Re: Rapid fire toggle script

25 Aug 2023, 01:33

Rohwedder wrote:
09 Aug 2020, 00:35
Then perhaps:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton, % (Toggle := !Toggle) ? "On" : "Off"
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
Hi, thank you before, I want to ask how if I want to make F8 as toggle on and F7 as toggle off the script ?
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script

25 Aug 2023, 03:41

Then:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton, On
*F7::Hotkey, *LButton, Off
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
frostwalter
Posts: 3
Joined: 25 Aug 2023, 01:30

Re: Rapid fire toggle script

29 Aug 2023, 13:31

Rohwedder wrote:
25 Aug 2023, 03:41
Then:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton, On
*F7::Hotkey, *LButton, Off
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
Thank you, I work perfectly.
Something comes to my mind, is it posible if we combine two of these function ?
I want F8 as toggle On and Off script, but also I want F7 as toggle Off script.
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script  Topic is solved

30 Aug 2023, 01:34

Then:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton,% (Toggle := !Toggle) ? "On" : "Off"
*F7::Hotkey, *LButton,% ("Off", Toggle := False)
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
frostwalter
Posts: 3
Joined: 25 Aug 2023, 01:30

Re: Rapid fire toggle script

30 Aug 2023, 11:16

Rohwedder wrote:
30 Aug 2023, 01:34
Then:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton,% (Toggle := !Toggle) ? "On" : "Off"
*F7::Hotkey, *LButton,% ("Off", Toggle := False)
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
Thank you again, one more thing, what if I want to put multiple key on one function, let say,
I want F8 as toggle on and off, and F7 as toggle off, but also Esc key as toggle off same as F7
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script

31 Aug 2023, 02:57

Then:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton,% (Toggle := !Toggle) ? "On" : "Off"
*Esc::
*F7::Hotkey, *LButton,% ("Off", Toggle := False)
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
You let a pattern of behavior show, but instead of asking for a key as toggle On script, you should learn Autohotkey yourself:
https://ahkde.github.io/docs/v1/Tutorial.htm
aaa666
Posts: 8
Joined: 16 Jun 2023, 14:49

Re: Rapid fire toggle script

23 Sep 2023, 16:50

Rohwedder wrote:
09 Aug 2020, 00:35
Then perhaps:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::Hotkey, *LButton, % (Toggle := !Toggle) ? "On" : "Off"
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
Hello, i'm sorry for bumping this post. But could u add SoundBeep to this script?
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Rapid fire toggle script

24 Sep 2023, 02:07

On/Off SoundBeep:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::
Hotkey, *LButton, % (Toggle := !Toggle) ? "On" : "Off"
SoundBeep, % Toggle*1000 + 1000
Return
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
aaa666
Posts: 8
Joined: 16 Jun 2023, 14:49

Re: Rapid fire toggle script

24 Sep 2023, 11:21

Rohwedder wrote:
24 Sep 2023, 02:07
On/Off SoundBeep:

Code: Select all

HotKey, *LButton, Off ;Initially, the Fast Fire part is deactivated
Return ;End of Auto-execute Section https://autohotkey.com/docs/Scripts.htm#auto
/::suspend
*F8::
Hotkey, *LButton, % (Toggle := !Toggle) ? "On" : "Off"
SoundBeep, % Toggle*1000 + 1000
Return
*LButton:: ;Fast Fire part
	SetMouseDelay 68
	While GetKeyState("LButton","P")
		Click
Return
Thank you so much! :superhappy:

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 59 guests