Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

page up / page down / escape chars work if inactive window, but not if active window

0 views
Skip to first unread message

Conshohocken Joe Conshy Joe

unread,
Jan 21, 2003, 10:12:24 AM1/21/03
to
Strange problem:

I have a console program that is supposed to respond in different ways
to the page up, page down, and escape buttons.

It is working if the console window is INACTIVE, and not working when
ACTIVE.

What the hell is going on?

The program looks generally like this...

int main()
{
short KeyStatus = 0;
while (true)
{
KeyStatus = GetAsyncKeyState(VK_PRIOR);
if ( KeyStatus == code that means button pressed )
{ foo(); continue; }

KeyStatus = GetAsyncKeyState(VK_NEXT);
if ( KeyStatus == code that means button pressed )
{ goo(); continue; }

KeyStatus = GetAsyncKeyState(VK_ESCAPE);
if ( KeyStatus == code that means button pressed )
{ moo(); continue; }
}

return 0;
}

where "code that means button pressed" =
"(KeyStatus & 0x01 == 1) || (KeyStatus & 0x8000 == 1)"

and basically means that the button was either pressed since the last
call to GetAsyncKeyState, or that the button is currently being held
down.
(or so I believe)

Tonu Aas

unread,
Jan 22, 2003, 4:59:46 AM1/22/03
to
> It is working if the console window is INACTIVE, and not working when
ACTIVE.
> What the hell is going on?

> KeyStatus = GetAsyncKeyState(VK_PRIOR);


> if ( KeyStatus == code that means button pressed )
> { foo(); continue; }

GetAsyncKeyState & friends are related to GUI, so in console program
they act as they wish. Mmm, but you can switch off from console and back and
then
get real values. Maye it works.

There are 3 types of keyboard drivers in windows: GUI, console & DOS
window.
And there are no information how they are related to each other.

Console keyboard handling and also console output are very buggy.
So dont expect nothing - this is "the hell" to write console program.

Tõnu, tried and tired.


0 new messages