1

Visual StudioのC#で、Internet Explorer 8 /(推奨)で現在開いている(または選択した、またはすべての)タブのhtmlソースを取得するプログラムを作成しようとしています。9。-ブラウザでコピーするのにうんざりしています。 ->ソースの表示、alt + a、alt + c、プログラム-> alt + v誰かがそれを解決する方法を知っていますか?

4

1 に答える 1

2

さて、これに対する簡単な解決策はありません。たぶん、コピーと貼り付けを続ける必要があると思います。とにかく、これは私がWebサーフィンで見つけたものです:(http://www.experts-exchange.com/Microsoft/Development/Q_23767759.html

{   // used spy++ to get the names of these guys
            // get the handle to the IE toolbar
            childHandle = FindWindowEx(IEwindowHandle, IntPtr.Zero, "WorkerW", IntPtr.Zero);
            if (childHandle != IntPtr.Zero)
            {
                //get the handle to the address bar on IE
                childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ReBarWindow32", IntPtr.Zero);
                if (childHandle != IntPtr.Zero)
                {
                    // get a handle to comboBoxEx32
                    childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBoxEx32", IntPtr.Zero);
                    if (childHandle != IntPtr.Zero)
                    {
                        // get a handle to combo box
                        childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBox", IntPtr.Zero);
                        if (childHandle != IntPtr.Zero)
                        {
                            //get handle to edit
                            childHandle = FindWindowEx(childHandle, IntPtr.Zero, "Edit", IntPtr.Zero);
                            if (childHandle != IntPtr.Zero)
                            {
                                // now to get the URL we need to get the Text - but first get the length of the URL
                                int length = SendMessage(childHandle, WM_GETTEXTLENGTH, 0, 0);
                                length += 1;    // because the length returned above included 0
                                StringBuilder text = new StringBuilder(length); // need stringbuilder - not string
                                int hr = SendMessage(childHandle, WM_GETTEXT, length, text); // get the URL
                                strURL = text.ToString();
                            }
                        }
                    }
                }

URLにアクセスしたので、HTTP Get Requestを送信すると、プレーンテキストでサイトソースが取得されます。

于 2010-10-30T14:24:28.167 に答える