Click to See Complete Forum and Search --> : How can i differentiate between "a" and "shift +a"(A) in WM_KEYDOWN event?
aneird
September 17th, 2007, 10:47 PM
How can i differentiate between "a" and "shift +a"(A) in WM_KEYDOWN event?
when sending WM_KEYDOWN message,how can i differentiate between "a" and "shift +a"(A)?
JVene
September 18th, 2007, 12:01 AM
You wrote "when sending"
You don't usually send keystroke messages, but if you're simulating keyboard input, simulate all of the keyboard input, including the user hitting the shift key, holding it, then tapping A, before releasing the shift key.
This may not always work as you expect, however.
Consider this about how applications MIGHT choose to retrieve keyboard information....
They can respond to the keydown or keyup, use GetKeyState to check the shift keys, call TranslateMessage, etc.
You may want to look into the function "SetKeyboardState" to see if you need that.
You may also want to study SendInput, which is meant to synthesize keystrokes, mouse motions and button clicks.
aneird
September 18th, 2007, 01:16 AM
oh,yes
Greggle
September 18th, 2007, 01:29 AM
Typically, you would process non-character-generating keystrokes with WM_KEYDOWN, e.g., the 'delete' key, 'insert' key, 'shift', 'ctrl' and suchlike. Use WM_CHAR for 'letters'(as it were).
Having said that, a WM_KEYDOWN message <i>will</i> be received by the window procedure if you press 'a', but immediately after that it will also receive a WM_CHAR message. Do your 'a' code there. After the WM_CHAR has done its thing, a WM_KEYUP is processed.
Either way, like JVene said, use GetKeyState() to determine whether 'shift' has been pressed. Check it against 'shift's' virtual key code, VK_SHIFT. It would look something like this...
nState = GetKeyState(VK_SHIFT);
aneird
September 18th, 2007, 03:34 AM
thank upstair friends!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.