Page 1 of 1
inkey() waits...
Posted: Thu Aug 28, 2003 11:13 pm
by DoubleDutch
the inkey() command seems to wait for an event, it only seems to function properly if the mouse is over the console window...
is there a way for inkey() to skip waiting for an event if the window is not being "looked at"....?
Inkey() depends upon an OpenConsole()
Posted: Sat Aug 30, 2003 8:50 pm
by oldefoxx
Inkey() only works if you have an OpenConsole(), and it does not wait for an input, but rather returns "" if no key is pressed, or the ASCII code of the key that is pressed. A good way to use it is as follows:
Code: Select all
OpenConsole()
Repeat
Until Inkey()>""
CloseConsole()
End
To get the same effect without using the console, take a look at KeyboardPushed() and the option to use #PB_Key_All to see if any key has been pressed.
Posted: Sun Aug 31, 2003 1:07 am
by DoubleDutch
I think that you may have misunderstood...
What I meant was that I AM in console mode, but when you do an Inkey(), the program will wait an event - either a mouse movement or whatever - try it... here is a clip from the main loop of the program (in console mode)...
Repeat
PrintAt(72,1,FormatDate("%hh:%ii:%ss",Date()))
ConsoleLocate(29,21)
Ascii$=UCase((Left(Inkey(),1)))
Select Ascii$
Case "1"
DoECD()
DisplayMain()
Case "2"
DoPT1()
DisplayMain()
Case "3"
DoEXCD()
DisplayMain()
EndSelect
Until Ascii$=Chr(#ESC)
CloseConsole()
(the PrintAt bit is just a procedure i made)...
From the above code, you would expect the program to constantly update the time while waiting for a key, nope!
What it does is hang (if no mouse movement or keyboard responce), no screen update!...
It does work, however if you do move the mouse about the console screen, or press any key...
Any solutions?