Jump to content

I want to run a function if only the numbers 1 to 24 are pressed on the keyboard.


Cor
 Share

Recommended Posts

This should give you a general idea of how to do that.

Global $Buffer
For $X = 0 To 9
    HotKeySet($X, "KeyHandler")
Next

While 1
    Sleep(100)
WEnd


Func KeyHandler()
    $Buffer &= @HotKeyPressed
    If StringLen($Buffer) = 3 Then
        $Buffer = @HotKeyPressed
        Return
    EndIf
    If StringLen($Buffer) <> 2 Then Return
    If $Buffer >= 1 And $Buffer <= 24 Then MsgBox(0, "Event", $Buffer)
EndFunc   ;==>KeyHandler

If you type any number between 1 and 24 it should fire off a msgbox. It should be noted that to type single digit numbers they need to be prefixed with a zero , eg. "01"

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
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...