使用下面发布的代码,我可以获取Internet Explorer窗口的窗口句柄并将其转换为IHTMLDocument2对象以读取html。除了启用远程调试以外,Chrome浏览器窗口是否还可以使用类似的东西?
IHTMLDocument2 document = null;
int lRes;
Trace.WriteLine("About to GetWindowHandleByTitle");
var hWnd = GetWindowHandleByTitle();
Trace.WriteLine("About to GetWindowHandleByTitle Complete");
EnumProc proc = EnumWindows;
EnumChildWindows(hWnd, proc, ref hWnd);
Trace.WriteLine("Found Child Window");
if (hWnd.Equals(IntPtr.Zero))
{
return null;
}
int lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
if (lngMsg == 0)
{
return null;
}
SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (lRes == 0)
{
return null;
}
ObjectFromLresult(lRes, ref IID_IHTMLDocument, 0, ref document);