Postmessage, Shift Key & control Key usage
Posted on 1999-07-22
I'm using VB6, but y'all should be able to answer this.
I tried to use the postmessage command to send keystrokes to MS Word 97 (I'm using Word 97 as a test of my program) from a VB program. I used the WM_KEYDOWN, WM_CHAR, and WM_KEYUP commands.
(I'm not creating a process instance, I'm just grabbing the hwnd of an already open app.)
The order of messages are:
1. WM_KEYDOWN shift
2. WM_KEYDOWN "A"
3. WM_CHAR "A"
4. WM_KEYUP "A"
What happens is that a capital A and a lowercase a is sent. When I remove the WM_CHAR, only one a is sent (lower case). When I put the caps lock on, then a capital A is sent. All of the values are &H41 (65 , letter A).
My suspiscion is that when I send the shift message, it doesn't "hold" while the next message is being sent, ie, when I send the a, it checks that status of the shift key.
I'm not sure if this is the way MS Word handles keystrokes, but I need to be able to send keystrokes this way (not via Sendkeys or COM or any way. I WANT to use the post message way).
My question is, how do I force Shift and letter combinations, and especially, how do I force Control and letter combinations via postmessage/sendmessage (send message won't work)? Do I have to force a caps locks? What about CTRL, since there is no CTRL lock?
There are some apps besides Word that I need to send control combinations (ie CTRL + Z)