Internet Explorer automation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Internet Explorer automation

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    6

    Question Internet Explorer automation

    Hello.
    I`m working with MSVS C++. I want to automate several routine actions in IE page using COM technology. Does anyone know some useful links about this?


    Code:
    	CIEAutoCntrItem* pItem = NULL;
    	TRY
    	{
    		CIEAutoDoc* pDoc = GetDocument();
    		ASSERT_VALID(pDoc);
    		pItem = new CIEAutoCntrItem(pDoc);
    		ASSERT_VALID(pItem);
    
    		HRESULT hr;
    		IWebBrowserApp* pWBApp = NULL; 
    		BSTR bstrURL = NULL, bstrHeaders = NULL;
    		VARIANT vFlags = {0},
                    vTargetFrameName = {0},
                    vPostData = {0},
                    vHeaders = {0};
    		
    		if (FAILED(hr = CoInitialize(NULL)))
    		  return;
    			
    		if (FAILED(hr = CoCreateInstance(CLSID_InternetExplorer,
                         NULL,
                         CLSCTX_SERVER,
                         IID_IWebBrowserApp,
                          (LPVOID*)&pWBApp)))
    		{
                        return;
    		}
    		
    		bstrURL = SysAllocString(L"google.com");
    		if (!bstrURL)
    		{
                          return;
    		}
    		
    		bstrHeaders = SysAllocString(L"Content-Type: application/x-www-form-urlencoded\r\n");
    		if (!bstrHeaders)
    		{
                      return;
    		}
    		
    		V_VT(&vHeaders) = VT_BSTR;
    		hr = pWBApp->Navigate(bstrURL, &vFlags,
    			&vTargetFrameName, &vPostData, &vHeaders);
    		pWBApp->put_Visible(VARIANT_TRUE);
    		 
    		ASSERT_VALID(pItem);
    		m_pSelection = pItem;   // set selection to last inserted item
    		pDoc->UpdateAllViews(NULL);
    	}
    	CATCH(CException, e)
    	{
    		if (pItem != NULL)
    		{
    			ASSERT_VALID(pItem);
    			pItem->Delete();
    		}
    		AfxMessageBox(IDP_FAILED_TO_CREATE);
    	}
    	END_CATCH
    In pWBApp i have pointer to IE process. How can i get: links, buttons, texts and other page objects?
    Last edited by cupuyc; January 29th, 2014 at 06:20 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center