我用SPY++知道了一个窗口的按键的ID(他是个自绘的按纽),想向他发送单击消息.比如是个0X0002455的值我该如何做呢?

解决方案 »

  1.   

    FindWindow() FindWindowEx()吧.
    spy++能知道窗口类名, 标题名, 窗口关系...
    就用两个函数配合找到窗口的HWND 然后调用API就可以了..
      

  2.   

    if (Process32First(handle,&info))

    while (Process32Next(handle,&info)) 
    {   
    CString exe;
    exe.Empty();
    exe.Format(L"%s",info.szExeFile); 
    if (exe == L"BlueSoleil.exe")
    {
    CString m_pszAppName = L"IVT Corporation BlueSoleil 主窗口";
    CWnd* hWnd = FindWindow(NULL, m_pszAppName);
    ::SetForegroundWindow(hWnd->m_hWnd);
    ::ShowWindow(hWnd->m_hWnd,SW_RESTORE);
    CWnd* pBtn2 = FindWindowExW(hWnd->m_hWnd,(这里该是子按键的HAND),L"Button",L"Local");
    //CString csTitle2 = _T("");
    //pBtn2->GetWindowText(csTitle2);
    ::PostMessage(hWnd->m_hWnd,WM_COMMAND,MAKEWPARAM(GetWindowLong(pBtn2->m_hWnd,GWL_ID),BN_CLICKED),(LPARAM)pBtn2->m_hWnd);
    return ;

    }
    }这是我的代码,但发消息就有错,能帮忙看下吗,这个按键的ID0x00020534