Sign in to follow this  
Followers 0
spymare

Hotkey set prevent loop

4 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

owh, thanks alot Manadar :) very usefull

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