Jump to content
Sign in to follow this  
Mazdryk

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

Recommended Posts

Mazdryk

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?

Share this post


Link to post
Share on other sites
Mazdryk
HotkeySet("x", "_HotFunc")

Func _HotFunc()
    HotkeySet("x")
    ;do stuff
    HotkeySet("x", "_HotFunc")
EndFunc

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

Share this post


Link to post
Share on other sites
somdcomputerguy

The problem is that I like to spam my hotkey..

Well I guess a simple solution would be to not spam the hotkey.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×