Sign in to follow this  
Followers 0
Blacktongue

Wait for Key ?

6 posts in this topic

This sounds simple but it's got a beginner stuck..

I want a message box to pop up and then disappear but then I want the script to wait for keyboard input.....

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

then what?

Thanks,

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

@BALA :

- Uppercase "a" requires you to press Shift+A, not just "a".

- Missing comma on MsgBox-line

- Script will close after MsgBox closes, due to missing keep-alive loop.

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