一个很严重的问题,我得不到ie里面的子窗口 找不到是正常的。那些东西只能通过IHTMLDocument2指针去获得。除非你要找的是一个ActiveX控件的窗口。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 难道ie里的字窗口不是windows HWND吗? ComboBox的类名我是通过spy++得到的,所以我想应该是正确的啦。sxbyl(白菜.NET) 能不能介绍一下IHTMLDocument2指针呢?我没有接触过。sorry2000(方言),不仅仅是ie里面的得不到,好象比如vc界面下的也得不到,是findwindowex不好用吗? IHTMLDocument2相关的东西你可以看MSDN,介绍得很详细。用IHTMLDocument2的get_all可以得到IHTMLElementCollection指针,通过IHTMLElementCollection的item可以得到一个对象的指针下面是我的一个函数void CSendMsgDlg::PutIEText(IHTMLElementCollection *pobjAllElement,CString strName,CString strText){ CComPtr<IDispatch>pDisp; pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp); CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement>pElement; if(pDisp==NULL) { AfxMessageBox(strName + "没有找到!"); } else { pElement=pDisp; pElement->put_value(strText.AllocSysString()); }} 我刚才看了看111222的文档,里面有用findwindowex的方法,大家去看看吧,sxbyl(白菜.NET) 你说的方法是需要有com的 知识吧,我还没有学过,可能需要一段时间来看看。 有个不明白的地方,为什么combobox可以是一个ComboBoxEx的子窗口呢? BOOL FindIeURL(){HWND hWorker,hRebar,hComEx,hcom,hEdit;HWND hwndParent=::FindWindow("IEFrame",NULL);//找到最近的IE,要是找到某个IE需要枚举所有的IE过筛子if(hwndParent == NULL)//没有IE运行中return FALSE;char szURL[260]; hWorker=FindWindowEx(hwndParent,0,"WorkerA",NULL);//找到工作区if(hWorker == NULL)//用户用NThWorker=FindWindowEx(hwndParent,0,"WorkerW",NULL);//WindowNT中的iehRebar=FindWindowEx(hWorker,0,"ReBarWindow32",NULL);//找到RebarhComEx=FindWindowEx(hRebar,0,"ComboBoxEx32",NULL);//找到Comboboxexhcom=FindWindowEx(hComEx,0,"ComboBox",NULL);//找到comboboxhEdit=FindWindowEx(hcom,0,"Edit",NULL);//找到ComBoBox的edit控件句柄 ::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szURL);AfxMessageBox(szURL);return TRUE;} 好像微软的MSDN里面有篇文章介绍从HWND怎么获得IWebBrowser接口的。有了IWebBrowser接口,你就可以通过DOM访问里面的元素。访问方式基本和脚本一样,比如Windows.document.all.itemID.innerText等等,只不过换成了相应COM接口的方法的调用。 以前我遇到过这道题,正好回答你.不知道你想做什么, 我关注,做好后给我一份. :)CWnd *pIEWnd;HWND hChild; //IE 地址栏句柄 UpdateData();m_WindowTitle = "http://student.tsinghua.edu.cn/ - Microsoft Internet Explorer";pIEWnd = CWnd::FindWindow(NULL,m_WindowTitle);if (pIEWnd == NULL){ MessageBox("Can`t Find the specified Window"); return; } MessageBox("Get the Father Window!!!"); hChild=FindWindowEx(pIEWnd,0,"ReBarWindow32",NULL); hChild=FindWindowEx(hChild, 0,"ComboBoxEx32",NULL); hChild=FindWindowEx(hChild, 0,"ComboBox",NULL); hChild=FindWindowEx(hChild, 0,"Edit",NULL); SendMessage(pIEWnd,WM_SYSCOMMAND,SC_MAXIMIZE,NULL); //最大化IE窗口 SetForegroundWindow(pIEWnd); //设置为当前窗口 SendMessage(hChild,WM_CHAR,'a',NULL);HWND hCombo = ::FindWindowEx(pIEWnd-> GetSafeHwnd(),NULL,"ComboBox",NULL); if (hCombo == NULL){MessageBox("Can`t find the ComboBox"); return; }MessageBox("Get the ComboBox!!!"); 哈哈,该送分了:) 请关注:http://www.csdn.net/expert/topic/411/411075.shtm分数为150分十万火级,如能给出答案,再送300分 可乐瓶的方法是最佳的, 可是如果没有Rebar, Combobox等, 又如何得到IE 访问的URL 呢? 去看看http://www.csdn.net/expert/topic/360/360785.shtm wav格式 求助,需要GDI+教程 MFC关于如何隐藏和显示主窗体 VC关于button问题 (MFC初学者问题)窗体类中:关于DoDataExchange方法 如何改变对话框的底色? ADO问题:请高手帮忙查看一下, unexpected end of file found Intel 的 TBB模块有用过的吗? 求助,mfc中用空格分割后的字符串输出问题 有谁知道.ram;.rm的文件格式,如另有要求可详谈 我想作一个数据库的程序,库文件可能会有好几百兆,我该用那种格式的数据库文件?
sxbyl(白菜.NET) 能不能介绍一下IHTMLDocument2指针呢?我没有接触过。
sorry2000(方言),不仅仅是ie里面的得不到,好象比如vc界面下的也得不到,是findwindowex不好用吗?
用IHTMLDocument2的get_all可以得到IHTMLElementCollection指针,通过IHTMLElementCollection的item可以得到一个对象的指针
下面是我的一个函数
void CSendMsgDlg::PutIEText(IHTMLElementCollection *pobjAllElement,CString strName,CString strText)
{
CComPtr<IDispatch>pDisp;
pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp);
CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement>pElement;
if(pDisp==NULL)
{
AfxMessageBox(strName + "没有找到!");
}
else
{
pElement=pDisp;
pElement->put_value(strText.AllocSysString());
}
}
sxbyl(白菜.NET) 你说的方法是需要有com的 知识吧,我还没有学过,可能需要一段时间来看看。
{HWND hWorker,hRebar,hComEx,hcom,hEdit;
HWND hwndParent=::FindWindow("IEFrame",NULL);//找到最近的IE,要是找到某个IE需要枚举所有的IE过筛子
if(hwndParent == NULL)//没有IE运行中
return FALSE;
char szURL[260];
hWorker=FindWindowEx(hwndParent,0,"WorkerA",NULL);//找到工作区
if(hWorker == NULL)//用户用NT
hWorker=FindWindowEx(hwndParent,0,"WorkerW",NULL);//WindowNT中的iehRebar=FindWindowEx(hWorker,0,"ReBarWindow32",NULL);//找到RebarhComEx=FindWindowEx(hRebar,0,"ComboBoxEx32",NULL);//找到Comboboxex
hcom=FindWindowEx(hComEx,0,"ComboBox",NULL);//找到comboboxhEdit=FindWindowEx(hcom,0,"Edit",NULL);//找到ComBoBox的edit控件句柄
::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szURL);AfxMessageBox(szURL);
return TRUE;
}
有了IWebBrowser接口,你就可以通过DOM访问里面的元素。访问方式基本和脚本一样,比如Windows.document.all.itemID.innerText等等,只不过换成了相应COM接口的方法的调用。
CWnd *pIEWnd;HWND hChild; //IE 地址栏句柄 UpdateData();m_WindowTitle = "http://student.tsinghua.edu.cn/ - Microsoft Internet Explorer";pIEWnd = CWnd::FindWindow(NULL,m_WindowTitle);if (pIEWnd == NULL){ MessageBox("Can`t Find the specified Window"); return; } MessageBox("Get the Father Window!!!"); hChild=FindWindowEx(pIEWnd,0,"ReBarWindow32",NULL); hChild=FindWindowEx(hChild, 0,"ComboBoxEx32",NULL); hChild=FindWindowEx(hChild, 0,"ComboBox",NULL); hChild=FindWindowEx(hChild, 0,"Edit",NULL); SendMessage(pIEWnd,WM_SYSCOMMAND,SC_MAXIMIZE,NULL); //最大化IE窗口 SetForegroundWindow(pIEWnd); //设置为当前窗口 SendMessage(hChild,WM_CHAR,'a',NULL);HWND hCombo = ::FindWindowEx(pIEWnd-> GetSafeHwnd(),NULL,"ComboBox",NULL); if (hCombo == NULL){MessageBox("Can`t find the ComboBox"); return; }MessageBox("Get the ComboBox!!!"); 哈哈,该送分了:)
http://www.csdn.net/expert/topic/411/411075.shtm
分数为150分
十万火级,如能给出答案,再送300分