原来的问题帖子在这里
http://topic.csdn.net/u/20081122/15/4a9d03ae-9541-4a1c-a58e-08b3f1172744.html?seed=984644095我是这样想的,利用全局钩子H,往程序P中发送消息 按键S
P程序,接收到消息按键S之后,拍照
全局钩子里的一段程序
case '1':
HWND hWnd;   
hWnd = FindWindow(NULL,"StillCap");   
if(hWnd   !=   NULL)   
{   
PostMessage(hWnd,XXXX,XXXX,XXXX);
                                        SendMessage(hWnd,XXXX,XXXX,XXXX);
}  
break;这个SendMessage和PostMessage消息应该怎样发?窗口句柄我已经获得了,但后面的参数该如何写??

解决方案 »

  1.   

    ::SendMessage(hWnd ,WM_KEYDOWN,'S',0);
    ::SendMessage(hWnd ,WM_KEYUP,'S',0);  
      

  2.   

    后面两个参数就是lparam,和rparam,要想一个传递地址,一个传递值,
    查查这方面资料,就能弄清楚了。
      

  3.   

    SendMessage
    The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately. LRESULT SendMessage(
      HWND hWnd,      // handle of destination window
      UINT Msg,       // message to send
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    );
     
    Parameters
    hWnd 
    Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. 
    Msg 
    Specifies the message to be sent. 
    wParam 
    Specifies additional message-specific information. 
    lParam 
    Specifies additional message-specific information. 
    Return Values
    The return value specifies the result of the message processing and depends on the message sent. 
      

  4.   

    PostMessage
    The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message. Messages in a message queue are retrieved by calls to the GetMessage or PeekMessage function. BOOL PostMessage(
      HWND hWnd,      // handle of destination window
      UINT Msg,       // message to post
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    );
     
    Parameters
    hWnd 
    Handle to the window whose window procedure is to receive the message. Two values have special meanings: Value Meaning 
    HWND_BROADCAST The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows. 
    NULL The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread. 
    Msg 
    Specifies the message to be posted. 
    wParam 
    Specifies additional message-specific information. 
    lParam 
    Specifies additional message-specific information. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, callGetLastError.