Sign in to follow this  
Followers 0
Noob

Run my function only once even if hotkey pressed several times while function running

3 posts in this topic

If WinActive("Notepad") Then

HotKeySet("a", "myfunction")

Else

HotKeySet("a")

EndIf

Func myfunction()

; my function includes several ControlClicks etc

EndFunc

Another question by Noob. I just don't know how to do this even after trying a variety of things since the weekend. Any help would be greatly appreciated.

* I only want the function to run once, even when the hotkey is pressed more then once while the function is running.

* When the function ends, then I want the function to be ready again to start when the hotkey is pressed.

* I don't want the function to be interrupted by multiple presses of the hotkey (or other hotkeys)

* I don't want the function to run multiple times when user mistakenly presses the hotkey multiple times

Share this post


Link to post
Share on other sites



Change function to

Func myfunction()
HotKeySet("a")
; my function includes several ControlClicks etc
HotKeySet("a", "myfunction")
EndFunc


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Wow, that did it for me! (I was agonizing a few days over this!)

Thanks VERY much!

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  
Followers 0