这个IE是个聊天室,我想有什么办法能够读出上面的对话内容,比如人家写给我的文字.谢谢!!!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4224/4224670.xml?temp=.9030878
    http://community.csdn.net/Expert/topic/4198/4198576.xml?temp=.3652155
      

  2.   

    #include <mshtml.h>
    #include <atlbase.h>
    #include <oleacc.h>BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
    {
    TCHAR buf[100]; ::GetClassName( hwnd, (LPTSTR)&buf, 100 );
    if ( _tcscmp( buf, _T("Internet Explorer_Server") ) == 0 )
    {
    *(HWND*)lParam = hwnd;
    return FALSE;
    }
    else
    return TRUE;
    };
    void CDlg::OnGetText(HWND hWnd) 
    {
    CoInitialize( NULL ); // Explicitly load MSAA so we know if it's installed
    HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
    if ( hInst != NULL )
    {
    if ( hWnd != NULL )
    {
    HWND hWndChild=NULL;
    // Get 1st document window
    ::EnumChildWindows( hWnd, EnumChildProc, (LPARAM)&hWndChild );
    if ( hWndChild )
    {
    CComPtr<IHTMLDocument2> spDoc;
    LRESULT lRes;

    UINT nMsg = ::RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
    ::SendMessageTimeout( hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes ); LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, _T("ObjectFromLresult") );
    if ( pfObjectFromLresult != NULL )
    {
    HRESULT hr;
    hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument, 0, (void**)&spDoc );
    if ( SUCCEEDED(hr) )
    {
    CComPtr<IDispatch> spDisp;
    CComQIPtr<IHTMLWindow2> spWin;
    spDoc->get_Script( &spDisp );
    spWin = spDisp;
             spWin->get_document(&spDoc.p);
                                                          IHTMLElement* pBody;
                                                         hr = spDoc->get_body(&pBody);
                                                         if SUCCEEDED(hr)) 
                                                         {
                                                            BSTR bstrHTMLText;
                                                           hr = pBody->get_outerText(&bstrHTMLText);
           //这个就是网页文本
                                                           CString strText= bstrHTMLText;
                                                           ......
                                                          SysFreeString( bstrHTMLText);
                                                          pBody->Release();
                                                       } }
    }
    } // else document not ready
    } // else Internet Explorer is not running
    ::FreeLibrary( hInst );
    } // else Active Accessibility is not installed
    CoUninitialize();
    }
      

  3.   

    http://www.codeproject.com/shell/AutomateShellWindow.asp