Sign in to follow this  
Followers 0
qwertylol

Keypress

4 posts in this topic

I know it's somewhere in the help file, but I can't find it.

How do I call a function with a press of a keyboard?

Share this post


Link to post
Share on other sites



HotkeySet

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

does it work from inside a loop to exit loop ?

Share this post


Link to post
Share on other sites

does it work from inside a loop to exit loop ?

HotKeySet() would be done before the loop, and defines a function to run when the key is pressed.

Once you enter the loop, and the key is pressed, the loop will be interrupted by defined function in the HotKeySet(). Once that function returns, it will go back to the loop. So it will interrupt the loop, but not exit it.

To exit a loop on a hot key, have the hot key's function change a flag that the loop is monitoring:

Global $ExitFlag = False
HotKeySet("{ESC}", "_ExitFlag")

$n = 0
While 1
    If $ExitFlag Then
        ExitLoop
    Else
        ConsoleWrite($n & @LF)
        $n += 1
    EndIf
    Sleep(1000)
WEnd
MsgBox(64, "Demo", "Demo is done.")

Func _ExitFlag()
    $ExitFlag = Not $ExitFlag
EndFunc   ;==>_ExitFlag

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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