Toggle a script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
NathanF3
Posts: 3
Joined: 04 Dec 2021, 15:43

Toggle a script

Post by NathanF3 » 04 Dec 2021, 15:53

Hi so I have a script wich is basicly an autoclicker (source: viewtopic.php?t=81465):

Code: Select all

RButton::
While GetKeyState("RButton","P")
{
	MouseClick right
	Sleep, 20 
}
Return
what it does is when I hold the click button, it spam click, but I would like to be able to toggle this features.
For example I launch the script, son when I hold clicks, it autoclick, but It stops doing that when I press a specific key (K for example) meaning I can use my mouse normally, but when I press the K key again, it once again acts as an autoclicker.
Is there any way of doing that?

User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: Toggle a script  Topic is solved

Post by Xtra » 04 Dec 2021, 16:19

Code: Select all

toggle := true

#If toggle
RButton::
While GetKeyState("RButton","P")
{
	MouseClick right
	Sleep, 20 
}
Return
#If

k::toggle := !toggle
or:

Code: Select all

RButton::
While GetKeyState("RButton","P")
{
	MouseClick right
	Sleep, 20 
}
Return

k::Suspend

Post Reply

Return to “Ask for Help (v1)”