streetglow Posted September 8, 2007 Share Posted September 8, 2007 Hello, how do I check for userinput? I only would like to know whether someone pressed arrow up or not... If he did press arrow up, there should appear a message box. *just doing some training* I know how to show a message box, but when I do this: if Send("{UP}") then MsgBox(0,"You clicked", "UP") EndIf I always get the messagebox. I hope someone can help me, thanks in advance. Streetglow. Link to comment Share on other sites More sharing options...
Gif Posted September 8, 2007 Share Posted September 8, 2007 (edited) #Include <Misc.au3> While 1 If _IsPressed('26') Then MsgBox(0,"You clicked", "UP") WEnd Edited September 8, 2007 by Gif Link to comment Share on other sites More sharing options...
streetglow Posted September 8, 2007 Author Share Posted September 8, 2007 Thanks a lot, could you please explain me why using the while loop? Link to comment Share on other sites More sharing options...
Gif Posted September 8, 2007 Share Posted September 8, 2007 if you dont use a loop in your program, it will almost immediatly end, so by using a loop the program remains active... look in the helpfile for more informations about loops Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 8, 2007 Share Posted September 8, 2007 In addition to what Gif, The Genius Guin, explained might think about adding a Sleep(100) so the CPU doesn't have a fit running through the loop. Anytime you use a loop it's advised to have a Sleep(100) or greater to make it easier on your CPU. To see what I'm talking about you can let your loop run 5 minutes with and without the Sleep(). So the revised code might could be #Include <Misc.au3> While 1 If _IsPressed('26') Then MsgBox(0,"You clicked", "UP") Sleep(100) WEnd Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now