can't send WM_KEYDOWN correctly?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sidooh
    New Member
    • Dec 2009
    • 9

    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(h wnd,buffer,50);
    MoveWindow(hwnd ,0,0,500,500,TR UE);
    SendMessage(hwn d,WM_KEYDOWN,VK _NUMPAD0,0);
    SendMessage(hwn d,WM_KEYUP,VK_N UMPAD0,0);
    printf("%d\n%s\ n",hwnd,buffer) ;

    }else{
    printf("%d\n",h wnd);
    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!
Working...