Spam button after 100 ms delay?

Ask gaming related questions
User avatar
Maped
Posts: 15
Joined: 08 Jul 2018, 15:52

Spam button after 100 ms delay?

11 Jul 2018, 16:21

Hi!
I made one code and I am almost happy with how it works:

Code: [Select all] [Download] GeSHi © Codebox Plus

~*LButton::
While GetKeyState("LButton","P")
{
Send {Blind}l
random, time, 25, 50
sleep, time
}
Return

I would like to add there LButton spam only if the LButton is pressed for a time longer than 100 ms. In the same time it should anyway spam L every 25-50 ms as seen above.

Also I would like to make a code which allows the same longer press function for keyboard F button. When i press it for less than 100 ms it should just click F, but after 100 ms it should spam F until I release it.

Please help me with that so I could give you the blessing of a sacred duck.
User avatar
evilC
Posts: 4337
Joined: 27 Feb 2014, 12:30

Re: Spam button after 100 ms delay?

13 Jul 2018, 10:31

If you want one script with two spam loops in it, you cannot use a While GetKeyState() loop
AHK can only run one loop at one time.
You would need to use SetTimer instead.

This doubly applies if you want to do long press type functionality
User avatar
Maped
Posts: 15
Joined: 08 Jul 2018, 15:52

Re: Spam button after 100 ms delay?

25 Jul 2018, 19:06

Thank you! :>

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 7 guests