| |

VerySource

 Forgot password?
 Register
Search
View: 669|Reply: 2

How to change the content of the IE Activex control embedded in the program?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 17:50:01
| Show all posts |Read mode
If you want to program and control the page for automation, it involves auto-filling the form and sending it, or in some cases modifying the content of the page element.
Question 06, Question 07
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-31 09:45:01
| Show all posts
///////////////////////////////////////////////////////// //////
// Fill input field in IE
// If it works, it is written by Deep Blue Traveller, otherwise I don't
// know who writes it ^ _ ^
///////////////////////////////////////////////////////// /////
#import <mshtml.tlb> // Internet Explorer 5
#import <shdocvw.dll>
#include "Shlwapi.h"
#pragma comment (lib, "Shlwapi.lib")
int _tmain (int argc, _TCHAR * argv [])
{
CoInitialize (NULL);
SHDocVw :: IShellWindowsPtr m_spSHWinds;
if (m_spSHWinds.CreateInstance (__ uuidof (SHDocVw :: ShellWindows)) == S_OK)
{
IDispatchPtr spDisp;
long nCount = m_spSHWinds-> GetCount ();
for (long i = 0; i <nCount; i ++)
{
_variant_t va (i, VT_I4);
spDisp = m_spSHWinds-> Item (va);
SHDocVw :: IWebBrowser2Ptr spBrowser (spDisp);
if (spBrowser! = NULL)
{
IDispatchPtr spDisp;
if (spBrowser-> get_Document (&spDisp) == S_OK&&spDisp! = 0)
{
MSHTML :: IHTMLDocument2Ptr spHtmlDocument (spDisp);
MSHTML :: IHTMLElementPtr spHtmlElement;
if (spHtmlDocument == NULL)
continue;
spHtmlDocument-> get_body (&spHtmlElement);
if (spHtmlDocument == NULL)
continue;
HRESULT hr;
MSHTML :: IHTMLElementCollection * pColl = NULL;
hr = spHtmlDocument-> get_all (&pColl);
if (pColl! = NULL&&SUCCEEDED (hr))
{
long lcount = 0;
pColl-> get_length (&lcount);
for (int i = 0; i <lcount; i ++)
{
_variant_t index;
index.vt = VT_I4;
index.intVal = i;
IDispatchPtr disp;
disp = pColl-> item (index, index);
if (disp == NULL)
hr = E_FAIL;
else
{
MSHTML :: IHTMLInputElementPtr pInput (disp);
if (pInput)
{
BSTR bstrtype;
pInput-> get_type (&bstrtype);
printf (_bstr_t (bstrtype));
if (StrCmpW (bstrtype, L "text") == 0)
{
pInput-> put_value (_bstr_t ("fill it"));
printf ("fill a field\n");
}
SysFreeString (bstrtype);
}
}

}
pColl-> Release ();
}
}

}
}

}
else
{
printf ("Shell Windows interface is not avilable\n");
}
CoUninitialize ();
return 0;
}
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-31 10:18:01
| Show all posts
There are some code snippets that might be inspiring to you
http://www.fruitfruit.com/vc/ie/iehtml.cpp
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list