試行錯誤中のコードの断片

ぐちゃぐちゃ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Hoge
{

    public partial class Form1 : Form
    {

        private MyWebBrowser wb;

        public Form1()
        {
            InitializeComponent();
            wb = new MyWebBrowser();
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
            wb.Visible = false;
            wb.IsAccessible = false;
            wb.Parent = null;
            wb.Hide();
            wb.SendToBack();
            wb.SuspendLayout();
            wb.Dock = DockStyle.None;
            wb.Bounds = Rectangle.Empty;
            wb.TabIndex = 0;
            wb.ScriptErrorsSuppressed = true;
            wb.ScrollBarsEnabled = false;
            wb.GotFocus += new EventHandler(wb_GotFocus);
            wb.ObjectForScripting = null;
            object o = wb.ActiveXInstance;
            Console.WriteLine();
        }

        void wb_GotFocus(object sender, EventArgs e)
        {
            Console.WriteLine("GOT FOCUS E = " + e);
        }

        private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //Console.WriteLine(wb.Document.Body.OuterHtml);
            Console.WriteLine(wb.Document.Body.InnerHtml);
            HtmlElementCollection hec = wb.Document.Body.GetElementsByTagName("script");
            
            foreach (HtmlElement he in hec)
            {
                he.Document.Write("");
            }
            Console.WriteLine("xx");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            wb.Navigate("http://mail.google.com/");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Interval = 3 * 1000;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            button3.Focus();
        }

    }
}