钩子中获取IHTMLDocument2接口的问题
16lz
2021-01-22
实现功能
双击网页,获取网页HTML内容。
Proc(stringlpszParentWindow)
在钩子中调整用就出错,不在钩子中能正常。
错误信息
未处理System.Runtime.InteropServices.COMException
Message="因为应用程序正在发送一个输入同步呼叫,所以无法执行传出的呼叫。(异常来自HRESULT:0x8001010D(RPC_E_CANTCALLOUT_ININPUTSYNCCALL))"
Source="Microsoft.mshtml"
ErrorCode=-2147417843
有没人来帮帮忙
双击网页,获取网页HTML内容。
//1.这个能正常
privatevoidbutton1_Click(objectsender,EventArgse)
{
Proc("百度一下,你就知道-WindowsInternetExplorer");
}
//2.钩子处理这代码,会出错
publicvoidOnDblClick(objectsender,MouseEventArgse)
{
Proc("百度一下,你就知道-WindowsInternetExplorer");
}
//根据窗口名称
privatevoidProc(stringlpszParentWindow)
{
stringlpszParentClass="IEFrame";//整个窗口的类名
IntPtrParenthWnd=newIntPtr(0);
IntPtrEdithWnd=newIntPtr(0);
IntPtrEdithWnd1=newIntPtr(0);
IntPtrEdithWnd2=newIntPtr(0);
UIntPtrlRes=newUIntPtr();
stringlpszClass="TabWindowClass";
stringlpszClass1="ShellDocObjectView";
stringlpszClass2="InternetExplorer_Server";
ParenthWnd=FindWindow(lpszParentClass,lpszParentWindow);
EdithWnd=FindWindowEx(ParenthWnd,EdithWnd,lpszClass,lpszParentWindow);
EdithWnd1=FindWindowEx(EdithWnd,EdithWnd1,lpszClass1,"");
EdithWnd2=FindWindowEx(EdithWnd1,EdithWnd2,lpszClass2,"");
uintApp2_GenerateEvent=RegisterWindowMessage("WM_HTML_GETOBJECT");
SendMessageTimeout(EdithWnd2,App2_GenerateEvent,newUIntPtr(0),IntPtr.Zero,SendMessageTimeoutFlags.SMTO_NOTIMEOUTIFNOTHUNG,1000,outlRes);
//这里得到IHTMLDocument2。钩子执行会出错
mshtml.IHTMLDocument2obj=(mshtml.IHTMLDocument2)ObjectFromLresult(lRes,typeof(mshtml.IHTMLDocument).GUID,IntPtr.Zero);
if(obj==null)
{
MessageBox.Show("No");
}
else
{
MessageBox.Show("YES");
}
}
Proc(stringlpszParentWindow)
在钩子中调整用就出错,不在钩子中能正常。
错误信息
未处理System.Runtime.InteropServices.COMException
Message="因为应用程序正在发送一个输入同步呼叫,所以无法执行传出的呼叫。(异常来自HRESULT:0x8001010D(RPC_E_CANTCALLOUT_ININPUTSYNCCALL))"
Source="Microsoft.mshtml"
ErrorCode=-2147417843
4 个解决方案
#1
有没人来帮帮忙
更多相关文章
- ExtJS的使用方法汇总(4)——拖放以及弹出窗口
- 如何将值发送到弹出窗口
- 解决主页在不同浏览窗口下浏览兼容——百分数值相对定位的总结
- PHP中钩子函数的实现与认识
- PHP的钩子实现解析
- MySQL---数据库从入门走向大神系列(三)-修改数据库编码/DOS窗口
- MySQL客户端输出窗口显示中文乱码问题解决办法
- js基础应用-打字机,震动窗口
- 可以使用不同文本框编辑的不同弹出窗口?