Jump to content

Run a Func once and do not allow it to be accessed until complete


Recommended Posts

I have a hotkey that runs a function for me that takes around 1 second to finish.  The problem is that I like to spam my hotkey and the func gets lagged and back logged and trys to run many instances at once.  How can I press a hotkey for a func and not allow that hotkey to run the func again until its first run is over?

Link to comment
Share on other sites

  • Developers

Doesn't work; it still allows me to run the function and the hotkey is still active and can be spammed.

Don't understand, so what about showing some code that has this problem!

Here is some code that demonstrates you can only run the Func one time and pressing the x constantly doesn't influence the execution of _HotFunc

hotkeySet("x", "_HotFunc")
hotkeySet("{END}", "_EndFunc")
While 1
    Sleep(50)
WEnd
;
Func _HotFunc()
    HotkeySet("x", "_DummyFunc")
    ConsoleWrite("Start _HotFunc():")
    For $x = 1 To 100
        ConsoleWrite(".")
        Sleep(10)
    Next
    ConsoleWrite("End _HotFunc()" & @CRLF)
    HotkeySet("x", "_HotFunc")
EndFunc
Func _DummyFunc()
    Return
EndFunc
;
Func _EndFunc()
    Exit
EndFunc

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...