|
-
March 25th, 2003, 02:06 PM
#1
Problem with Retreiving keystates
I am using keybd_event to set the NUMLOCK on / off.
The keyboard's NUMLOCK state before executing is OFF.
Now I use keybd_event and set the NUMLOCK state to ON.
Then , while trying to retrieve the NUMLOCK keystate through GetKeyState() / GetAsyncKeyState() / GetKeyboardState() , the return value is OFF (ie) 0. But the actual key state is ON.
The GetKeyState() is returning the values of the keystate previous to the calls given to keybd_event. It is not considering the keystate changed due to keybd_event. Could any one help me in this regard.
I want the correct keystate to be retreived even after a keybd_event.
My code is this:
//Keyboard NUMLOCK is OFF
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 );
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
short s = GetKeyState(VK_NUMLOCK);
BYTE nState1= LOBYTE(s);
BYTE nState2= HIBYTE(s);
//nstate1 is returning 0 instead of 1.
Thank you
Regards
Wajeed
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
|