|
public partial class Form1 : Form { bool mHooked; public Form1() { InitializeComponent(); webBrowser1. DocumentCompleted += webBrowser1_DocumentCompleted; webBrowser1. Navigate("hxxp: www. google. com"); }
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (mHooked) return; // Get the form HtmlDocument doc = webBrowser1. Document; HtmlElement form = doc. Forms["f"]; // Get the "I'm feeling lucky" button HtmlElement lucky = form. All["btnI"]; lucky. Click += lucky_Click; mHooked = true; } void lucky_Click(object sender, EventArgs e) { this. Close(); } }
You'll need a good DOM browser to find the button in your page if you don't know its name. =================
Search Engine Optimisation UK | Link Building
|