COM 通过查找IE窗口切换IE选项卡
来源:互联网 发布:adobe flash mac版 编辑:程序博客网 时间:2024/06/12 23:59
枚举不出隐藏的选项卡,只能枚举出显示出来的选项卡 HRESULT hRes;HWND MainIEWnd;HWND CommandBarWnd;HWND ReBarWnd;HWND TabBandWnd;HWND DirectUIWnd;BSTR tabCaption;long TabsCount=0,TabsReceived=0,newRes;IAccessible *tabsAccess,*tabObject,*newObj;IDispatch *tabDisp,*tab1;VARIANT ChildStruct[MAX_PATH],tabStruct[MAX_PATH],tabQueryStruct,tabResStruct;tabQueryStruct.vt=VT_I4;tabQueryStruct.lVal=CHILDID_SELF;MainIEWnd=::FindWindow(L"IEFrame",NULL);if(!MainIEWnd){AfxMessageBox(L"DEBUG: Unable to find main IE window");return;}CommandBarWnd=::FindWindowEx(MainIEWnd,NULL,L"WorkerW",NULL);if(!CommandBarWnd){AfxMessageBox(L"DEBUG: Unable to find CommandBarWindow");return;}ReBarWnd=::FindWindowEx(CommandBarWnd,NULL,L"ReBarWindow32",NULL);if(!ReBarWnd){AfxMessageBox(L"DEBUG: Unable to find ReBarWindow32");return;}TabBandWnd=::FindWindowEx(ReBarWnd,NULL,L"TabBandClass",NULL);DWORD n = GetLastError();if(!TabBandWnd){CString Str;Str.Format(L"%d", n);AfxMessageBox(L"DEBUG: Unable to find TabBandClass" + Str);return;}DirectUIWnd=::FindWindowEx(TabBandWnd,NULL,L"DirectUIHWND",NULL);n = GetLastError();if(!DirectUIWnd){CString Str;Str.Format(L"%d", n);AfxMessageBox(L"DEBUG: Unable to find DirectUIHWND" + Str);return;}if(AccessibleObjectFromWindow(DirectUIWnd,OBJID_CLIENT,IID_IAccessible,(void **)&tabsAccess)!=S_OK){AfxMessageBox(L"DEBUG: Unable to get IAccessible interface");return;}hRes=tabsAccess->get_accChildCount(&TabsCount); // get objects countif(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: Unable to get Objects count");return;}hRes=AccessibleChildren(tabsAccess,0,TabsCount,ChildStruct,&TabsReceived);if(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: Unable to get objects");return;}for(int i=0;i<TabsReceived;i++) // enum objects{if(ChildStruct[i].vt==VT_DISPATCH){tabDisp=ChildStruct[i].pdispVal;hRes=tabDisp->QueryInterface(IID_IAccessible,(void **)&tabObject);if(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: QueryInterface to tabObject failed");continue;}hRes=tabObject->get_accRole(tabQueryStruct,&tabResStruct);if(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: Unable to receive object role");continue;}if(tabResStruct.lVal!=ROLE_SYSTEM_PAGETABLIST) // we need only PageControl ! skipcontinue; // another contorlstabsAccess=tabObject; // we found PageControl with IE7 tabs !hRes=tabsAccess->get_accChildCount(&TabsCount); // number of opened tabs + New Tab buttonif(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: tab count failed");continue;}hRes=AccessibleChildren(tabsAccess,0,TabsCount,tabStruct,&newRes);for(int j=0;j<newRes;j++) // enum tabs{tab1=tabStruct[j].pdispVal;hRes=tab1->QueryInterface(IID_IAccessible,(void **)&newObj);if(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: QueryInterface to newObj failed");continue;} hRes=newObj->get_accName(tabQueryStruct,&tabCaption); if(!SUCCEEDED(hRes)){AfxMessageBox(L"DEBUG: Unable to receive tab caption");continue;} CString StrCaption = tabCaption;if(wcscmp(StrCaption, L"hao123_上网从这里开始") == 0)// make this f..g tab active !!!!newObj->accDoDefaultAction(tabQueryStruct);}}}
阅读全文
0 0
- COM 通过查找IE窗口切换IE选项卡
- 通过注册表修改IE的Internet选项
- 通过注册表修改IE的Internet选项
- 兼容ie的选项卡
- 通过LotusScrpit调用IE COM的方法
- IE浏览器怎样始终在新选项卡中打开弹出窗口
- IE 浏览器设置 打开新的选项卡而不是弹出窗口
- 通过注册表设置IE的ActiveX运行选项
- IE中设置多选项卡
- 设置 IE 选项值
- 查找IE窗口里的submit按钮,模拟点击
- Delphi通过IE窗口句柄获取网页接口(IWebBrowser2)
- 使用IE测试COM
- COM-IE-(1)
- COM-IE-(2)
- IE选项变灰白 IE总是空白 IE打不开网页
- 探索IE浏览器窗口
- IE弹出窗口打不开
- FFMPEG学习【libavformat】:Muxing
- Linux /centos 下nginx rpm包安装及配置
- Java学习之double类型数据比较
- 关于队列背包栈的认识
- JAVA为什么存在内部类?
- COM 通过查找IE窗口切换IE选项卡
- 老罗的Android之旅
- Eclipse标准版安装Web and JavaEE插件
- Swift: 删除子View
- 梯度下降法求解线性回归问题
- 谱聚类(spectral clustering)原理总结
- LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
- 2017.06.13回顾 series筛选赋值不是deepcopy?
- CLH锁与MCS锁