Page 1 of 1

Loop with Random sleep

Posted: 22 Jan 2016, 03:49
by Chroma
I'm looking for a loop that I can use that will also allow for random ms between each input and would also like for it to loop when I hold the key down and to stop looping once I release the key. I have searched through the forums for a bit and found a topic from a long time ago that had a lot of the things that I wanted. I had tried adding a variety of random sleep input methods but kept getting errors when that was added in. Could anyone help suggest how to properly insert a random sleep into this input. I'm also up for a suggestion of a better code if this one isn't optimal. Also, is there anyway I can add multiple keys to work for this loop without having to retype the code each time? Thanks for the time and sorry for the noob questions, I'm just completely confused/getting aggravated lol. *Final note, this will be used for playing video games that require a lot of clicking which is why I'm looking for this script, just thought I would mention that in case it would help with anything. -Thanks!

Ins::Suspend
SendMode Input
~$*Space::
Loop
{
Send {Space up}
Sleep 0 ;change 0 to whatever you want. 1000 = 1 second
Send {Space down}
Sleep 0 ;change 0 to whatever you want. 1000 = 1 second
If (GetKeyState("Space","P")=0)
{
Send {Space up}
Break
}
}
Return

Re: Loop with Random sleep

Posted: 22 Jan 2016, 09:29
by sinkfaze

Code: Select all

SendMode Input


Ins::Suspend 


~$*Space:: 
Loop 
{
	Random, d1, 15, 1000 
	Random, d2, 15, 1000
	Send {Space up}
	Sleep %d1%
	Send {Space down}
	Sleep %d2%
	If	(GetKeyState("Space","P")=0)
	{
		Send {Space up}
		Break 
	}
}
Return