实现功能
双击网页,获取网页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


有没人来帮帮忙

更多相关文章

  1. ExtJS的使用方法汇总(4)——拖放以及弹出窗口
  2. 如何将值发送到弹出窗口
  3. 解决主页在不同浏览窗口下浏览兼容——百分数值相对定位的总结
  4. PHP中钩子函数的实现与认识
  5. PHP的钩子实现解析
  6. MySQL---数据库从入门走向大神系列(三)-修改数据库编码/DOS窗口
  7. MySQL客户端输出窗口显示中文乱码问题解决办法
  8. js基础应用-打字机,震动窗口
  9. 可以使用不同文本框编辑的不同弹出窗口?

随机推荐

  1. android中设置控件获得焦点
  2. Android(安卓)RecyclerView更新删除单条
  3. [意见反馈][官方博客]
  4. Android 存储方式之文件存储
  5. Android 系统架构图
  6. 调用android系统自带功能
  7. Android天气预报
  8. Android 编译系统(一):Android.mk的学习
  9. android与socket通讯(三)
  10. Android之判断时间是否为今天