1

使用下面发布的代码,我可以获取 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);
4

0 回答 0