Jump to content

Wait for Key ?


Recommended Posts

Another way.

#include <Misc.au3>

$timeout = 5
MsgBox(0,"","Choose- press A , B, or C",$timeout) 
$dll = DllOpen("user32.dll")
While 1
    Sleep ( 50 )
    If _IsPressed("41", $dll) Then
        MsgBox(0,"_IsPressed", "A Key Pressed")
        ExitLoop
    EndIf
    If _IsPressed("42", $dll) Then
        MsgBox(0,"_IsPressed", "B Key Pressed")
        ExitLoop
    EndIf
    If _IsPressed("43", $dll) Then
        MsgBox(0,"_IsPressed", "C Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)
Link to comment
Share on other sites

Using Hotkeys:

#include <Misc.au3>

;'!' = 'Shift +'
HotKeySet("!a", "A")
HotKeySet("!b", "B")
HotKeySet("!c", "C")


MsgBox(0, "", "Choose- press A , B, or C")

Func A()
    ;put code here for if the user presses A
EndFunc

Func B()
    ;put code here for if the user presses B
EndFunc

Func C()
    ;put code here for if the user presses C
EndFunc

;'keep alive' loop
While 1
    Sleep(10)
WEnd

EDIT: fixed code

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
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...