Jump to content

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


Noob
 Share

Recommended Posts

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

Link to comment
Share on other sites

Change function to

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


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

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...