While loop when button is held down

Ask gaming related questions
barbieqfreak
Posts: 2
Joined: 10 Jul 2018, 13:00

While loop when button is held down

Post by barbieqfreak » 10 Jul 2018, 13:06

Just a little something I'm working on... not quite sure why this isn't working. I want to send the series of commands while the button is held down.

Code: Select all

XButton2::
{
	while GetKeyState XButton2
	{
		Send \
		Sleep 250
		Send q
		Sleep 6
		Send q
		Sleep 150
	}
}
return
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: While loop when button is held down

Post by Qysh » 10 Jul 2018, 13:17

Code: Select all

XButton2::
{
	while (GetKeyState("XButton2", "p"))
	{
		Send \
		Sleep 250
		Send q
		Sleep 6
		Send q
		Sleep 150
	}
}
return
barbieqfreak
Posts: 2
Joined: 10 Jul 2018, 13:00

Re: While loop when button is held down

Post by barbieqfreak » 10 Jul 2018, 13:37

Thanks! Any idea why we had to specify the physical state of the mouse side button?
Rohwedder
Posts: 1351
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: While loop when button is held down

Post by Rohwedder » 23 Jul 2018, 03:59

Hallo,
with a Tilde you don't need the physical state:

Code: Select all

~XButton2:: ;XButton's native function will not be blocked!
	while GetKeyState("XButton2")
	{
		Send \
		Sleep 250
		Send q
		Sleep 6
		Send q
		Sleep 150
	}
return
Post Reply

Return to “Gaming”