{
CWnd *pWnd = NULL 
pWnd  = FindWindow(_T("#32770"), "测试");
    if (pWnd)
    {
        CWnd *pBtn = pWnd->FindWindow(_T("Button"), "发送");
        if (pBtn )
        {
        
        }
        else
        {
            MessageBox("发送失败");
        }
}

解决方案 »

  1.   

    HWND hWnd = ::FindWindow(NULL, _T("测试"));
    if(hWnd)
    {
    HWND hButton = ::FindWindowEx(hWnd, NULL, NULL, _T("发送"));
    if(hButton)
    {
    AfxMessageBox(_T("OK"));
    }
    }
      

  2.   

    你Debug下跑一下,应该是你的CWnd指针为NULL了
      

  3.   

    HWND hWnd  = ::FindWindow(_T("#32770"), "测试");
    if (hWnd)
    {
    HWND  hBtnWnd = ::FindWindowEx(hWnd,NULL,_T("Button"), "发送");
    if ( hBtnWnd )
    {
    CString strText;
    ::GetWindowText(hBtnWnd, strText.GetBuffer(256), 256);
    strText.ReleaseBuffer();
    MessageBox(strText);
    ::SendMessage(hBtnWnd, WM_COMMAND, 0, 0);
    ::SendMessage(hBtnWnd,WM_LBUTTONUP, 0, 0);
    }
    else
    { MessageBox("发送失败!");
    }
    }现在是按钮找到了,但是消息发送不成功