Don't you hate it when people ignore your advice? Do exactly what anonytmouse said:
Code:
keybd_event(VK_SHIFT, NULL, KEYEVENTF_EXTENDEDKEY, NULL); // Key down
keybd_event(0x32, NULL, NULL, NULL); // Key down
keybd_event(0x32, NULL, KEYEVENTF_KEYUP, NULL); // Key up
keybd_event(VK_SHIFT, NULL, KEYEVENTF_KEYUP|KEYEVENTF_EXTENDEDKEY, NULL); // Key up
Note: I also removed the extended key flag from the second line, it's not necessary.
I also think it's a good idea to use FindWindow() with the class name rather than the window text:
Code:
HWND hParent = FindWindow("Notepad", NULL); // Find window
EDIT: You also don't need to specify extended key for SHIFT, I think that just makes it right shift instead of left shift. So, the following is fine:
Code:
keybd_event(VK_SHIFT, NULL, NULL, NULL);
keybd_event(0x32, NULL, NULL, NULL);
keybd_event(0x32, NULL, KEYEVENTF_KEYUP, NULL);
keybd_event(VK_SHIFT, NULL, KEYEVENTF_KEYUP, NULL);