Jump to content
Sign in to follow this  
Ult902

func() help

Recommended Posts

Ult902

ok i have a kotkey set to call a func, which types "a" to make it simple. theres only about 100ms worth of delay in there, but if i hold the hotkey it repeats faster than it should. which is pretty much spamming the func. is there any way to block a func from being called while a func is already running?

Share this post


Link to post
Share on other sites
Kealper

This should do what you want, I commented everything so you can see what is what (if you didn't already know)

HotKeySet("f", "Function") ;Set the key "f" to call function "Function"

Global $SpamTimer = TimerInit() ;Initialize a timestamp to $SpamTimer

While 1
    Sleep(1000) ;Sleep for 1 second to keep the script running idle while nothing is happening
WEnd

Func Function()
    If TimerDiff($SpamTimer) < 100 Then Return ;Check if the timestamp in $SpamTimer is more than 100ms old, if not, exit the function without doing anything
        Send("a") ;Send the keystroke
        $SpamTimer = TimerInit() ;Put a new timestamp in $SpamTimer
EndFunc

Share this post


Link to post
Share on other sites
CodyBarrett

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.