|
-
Aug 13th, 2002, 10:02 AM
#1
Thread Starter
Ya ya Baby!!!Me is Back
Get ESC character from console
cin doesn't work so I think the API : ReadConsoleInput can but I cannot put it work well.
Here is what I have :
PHP Code:
char c;
PINPUT_RECORD lpBuffer=0;
LPDWORD lpNumberOfEventsRead =0;
ReadConsoleInput(NULL,lpBuffer,1,lpNumberOfEventsRead);
c = lpBuffer.KEY_EVENT;
-
Aug 13th, 2002, 10:14 AM
#2
Thread Starter
Ya ya Baby!!!Me is Back
Here is what I have but it doesn't work better :
PHP Code:
PINPUT_RECORD lpBuffer=0;
LPDWORD lpNumberOfEventsRead =0;
ReadConsoleInput(new HANDLE,lpBuffer,1,lpNumberOfEventsRead);
char c;
c = (char)lpNumberOfEventsRead;
cout << "here : " << c << " ";
-
Aug 13th, 2002, 10:36 AM
#3
Thread Starter
Ya ya Baby!!!Me is Back
PHP Code:
..........
HANDLE hStdin;
INPUT_RECORD irInBuf[1];
hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD cNumRead;
char c;
do
{
//cin.get(c);
SetXY(8,8);
ReadConsoleInput(
hStdin, // input buffer handle
irInBuf, // buffer to read into
1, // size of read buffer
&cNumRead); // number of records read
if (irInBuf[0].EventType == KEY_EVENT)
c = irInBuf[0].Event.KeyEvent.uChar.AsciiChar;
cout << "here : " << c << " ";
..........
that work but it doesn't let me write anything in the console and it show a weird character to the screen.
Anyone know how to get ESC char and ARROW char from the console ?
-
Aug 13th, 2002, 12:05 PM
#4
Thread Starter
Ya ya Baby!!!Me is Back
How can I read all character tapped in the console even ESCAPE and ARROW character ?
-
Aug 13th, 2002, 12:36 PM
#5
Thread Starter
Ya ya Baby!!!Me is Back
Is there a way to get character from the console without using CIN ?
-
Aug 14th, 2002, 02:31 AM
#6
Thread Starter
Ya ya Baby!!!Me is Back
I use getch() of conio.h for the moment but I am sure that it have an other way.
-
Aug 14th, 2002, 04:11 AM
#7
PowerPoster
I think you can use getchar(). Don't think it'll process ESC or ARROWS keys though.
-
Aug 14th, 2002, 06:26 AM
#8
Frenzied Member
conio is just exactly what you want - console i/o.
Don't blindly assume api's are the best choice. Base C & C++ i/o calls are extremely efficient.
-
Aug 14th, 2002, 08:09 AM
#9
Thread Starter
Ya ya Baby!!!Me is Back
I know but I did not want to include all conio.h when I need only getch().
-
Aug 14th, 2002, 08:57 PM
#10
Frenzied Member
It's not a waste - the linker only brings in code to support what you use, not everything in an include file
-
Aug 15th, 2002, 07:18 PM
#11
Thread Starter
Ya ya Baby!!!Me is Back
hummm I didn't know, cool
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|