I think you should forget about GetKeyboardState(). I couldn't get it working in either MFC or win32. It always fail and give me back a null pointer.
I would suggest you to use back GetAsyncKeyState().
I have attached a working code which uses GetAsyncKeyState(). This program can detect up to any 3 keys simultaneously.(VK_SPACE is to quit). Modify it to your needs or up to more than 3 keys (don't worry;very easy to do).
But I would suggest you use it this way. Eg, you want to detect 4 keys, A, B, C, D.
PHP Code:
if(GetAsyncKeyState(0x41) & 0x8000)//==A key pressed
{
//Do what you want here
}
if(GetAsyncKeyState(0x42) & 0x8000)//==B key pressed
{
//Do what you want here
}
if(GetAsyncKeyState(0x43) & 0x8000)//==C key pressed
{
//Do what you want here
}
if(GetAsyncKeyState(0x44) & 0x8000)//==D key pressed
{
//Do what you want here
}
To use my code, use appwizard to generate a Win32 hello world app. Name the project SteveWin32. then copy my cpp file there.
Note: I don't know if you can just compile it without doing all these.
thanks so much for answering...but I have to use a console application...and in the console I've never gotten GetAsyncKeyState() to work for the keyboard (works for the mouse)...
thats why I was trying GetKeyboardState().
is there a way to make it work in a win32 console?
I think not, and under normal circumstances (that is when you want to write an app that does something useful, not a school project) you don't need it.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.