|
-
April 9th, 2010, 10:22 AM
#1
can't send WM_KEYDOWN correctly?
Hi,everyone!
I'm tring to write a program to send key press message to other program(such as notepad).I mean if I press "M" in my program,this "M" will append to the notepad text entry.
here is my code:
hwnd = FindWindow(NULL,"Untitled - Notepad");
if(hwnd!=0){
char buffer[100] = "";
GetWindowText(hwnd,buffer,50);
MoveWindow(hwnd,0,0,500,500,TRUE);
SendMessage(hwnd,WM_KEYDOWN,VK_NUMPAD0,0);
SendMessage(hwnd,WM_KEYUP,VK_NUMPAD0,0);
printf("%d\n%s\n",hwnd,buffer);
}else{
printf("%d\n",hwnd);
printf("failure\n");
}
After running this program,the MoveWidnow() function worked,but there isn't any character in notepad text entry...
What should I do to solve this problem?
Any suggestion is appreciated!
Last edited by linkstack; April 9th, 2010 at 10:35 AM.
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
|