Jump to content

Hotkey set prevent loop


spymare
 Share

Recommended Posts

Hi. Is it possible to prevent hotkeyset from making a loop when holding down a button, "in this case "ESC"

If you hold down esc, it keeps writing the date alot of times :/.

HotKeySet("{ESC}", "test")

While 1

Sleep(100)

WEnd

Func test()

Send("Today's time/date is {F5}")

EndFunc

Link to comment
Share on other sites

Hey spymare, this is a possible solution:

#include <Misc.au3> ; Required for ispressed
HotKeySet("{ESC}", "test")

While 1
Sleep(100)
WEnd

Func test()
    HotKeySet("{ESC}") ; Unbind escape so function is not called again
    Send("Today's time/date is {F5}")
    While _IsPressed("1B") ; While escape is held down
        Sleep(50) ; do nothing
    WEnd
    ; Once escape is released, rebind the hotkey
    HotKeySet("{ESC}", "test")
EndFunc
Link to comment
Share on other sites

well I guess I could just use ispressed instead:

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1

If _IsPressed("23", $dll) Then

Send("Today's time/date is {F5}")

sleep(200)

EndIf

WEnd

but i would prefer hotkeyset :).

Edited by spymare
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...