我在KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)将收到的消息记录在stRecord[]中,然后循环使用postmessage如下,
hWnd = GetForegroundWindow();PostMessage(hWnd, WM_KEYDOWN, stRecord[i].wParam, stRecord[i].lParam)但是接收窗口总是没有响应,问题出在哪里了,是不是lParam需要重新赋值?请指点!

解决方案 »

  1.   

    用KeyBoardEvent函数可以生成键盘消息
      

  2.   

    keyboardevent我没仔细看,他能将消息发送给其他窗口吗?
      

  3.   

    void Write()
    {
    HWND hWnd;
    int i;
    while(gbWrite)
    {
    for(i=0;i<nRecordNum;i++)
    {
    //send message to system here
    hWnd = GetForegroundWindow();

    if(HIWORD(stRecord[i].lParam)&KF_UP==0)
    {
    if(PostMessage(hWnd, WM_KEYDOWN, stRecord[i].wParam, stRecord[i].lParam)==0)
    {
    MessageBox(NULL,"wrong","",0);
    return;
    }
    }
    else
    {
    if(PostMessage(hWnd, WM_KEYUP, stRecord[i].wParam, stRecord[i].lParam)==0)
    {
    MessageBox(NULL,"wrong","",0);
    return;
    }
    }
    [i].nCode,stRecord[i].wParam, stRecord[i].lParam); Sleep(5000);
    }
    MessageBeep(-1);
    Sleep(50000);
    }
    }这是回写的代码,一开始我以为发送的太快,加了sleep之后,接受键盘消息的窗口还是没有响应,郁闷了点,是不是postmessage中的参数不对,msdn上写的太简单了啊
      

  4.   

    keyboardevent是模拟键盘消息。:)