请教高手!现在有某些自动填表工具可以自动向网页文本框里添加信息,
这是如何实现的呢?是基于句柄的吗?
请给些资料或者思路啊!谢谢谢谢谢谢啊~~~~
这是如何实现的呢?是基于句柄的吗?
请给些资料或者思路啊!谢谢谢谢谢谢啊~~~~
解决方案 »
- opengl中对于天空盒,怎么把观察者放在内部
- class CTabView:public CCtrlView
- 用AfxBeginThread建立的线程,但退出是怎样终止这个线程啊?
- 跪求代码,就这么点分了全放了
- 一个netmeeting登录到目录服务器的问题
- 50分求一IP小问题
- 在installshelled里面用软盘发布为什么说容量小?--高手救急
- --- VC + ACCESS 的问题---
- 怎么解决循环的#include
- 怎么找到所有系统com组件以及组件的说明
- 请教CDC::DRAWTEXT()的使用
- 在用户界面线程里建立了一个对话框,为什么将对话框关闭了,但线程仍不结束?(临贴涕泠,以待回复)
//Fill input field in IE
//If it works, it is written by masterz,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;
}