using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
//新添加命名空间
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
namespace WebBrowserCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webBrowser1.Url = new Uri("http://www.baidu.com");
}
private void Form1_Load_1(object sender, EventArgs e)
{
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElement tbUserid = webBrowser1.Document.All["username"];
HtmlElement tbPasswd = webBrowser1.Document.All["password"];
HtmlElement btnSubmit = webBrowser1.Document.All["login"];
if (tbUserid == null || tbPasswd == null || btnSubmit == null)
{
webBrowser1.GoBack();
}
tbUserid.SetAttribute("value", "XXXX");
tbPasswd.SetAttribute("value", "XXXX");
btnSubmit.InvokeMember("click");
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Show();
this.WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
}
}
}
记得在窗体的事件的SizeChanged添加form1_resize