日期:2014-05-17 浏览次数:20964 次
#region 获取网页回复按钮 private void button1_Click(object sender, EventArgs e) { HtmlElement htmlBtn = webBrowser1.Document.GetElementById("imageField"); htmlBtn.InvokeMember("click"); } String huifucishu = "";//初始化回复次数 #endregion #region 文本1打印 private void button2_Click(object sender, EventArgs e) { try { HtmlElement tbUserid = webBrowser1.Document.All["post_body"]; string Run = ""; Run = textBox1.Text; //文字打印 tbUserid.SetAttribute("value", Run); tbUserid.InvokeMember("click"); button1_Click(sender, e); //3秒不可点击 huifu1.Enabled = false; huifu2.Enabled = false; Timer1.Interval = 3100;//3.1秒 Timer1.Enabled = true; huifu2.BringToFront(); //回复次数计算 huifucishu = label8.Text = (Convert.ToInt32(label8.Text) + 1).ToString(); } catch (Exception) { MessageBox.Show("你日你妹,还没加载完毕呢"); } } #endregion #region 文本2打印 private void button3_Click(object sender, EventArgs e) { try { HtmlElement tbUserid = webBrowser1.Document.All["post_body"]; string Run = ""; Run = textBox2.Text; tbUserid.SetAttribute("value", Run); tbUserid.InvokeMember("click"); button1_Click(sender, e); //3秒不可点击 huifu1.Enabled = false; huifu2.Enabled = false; Timer1.Interval = 3100;//3.1秒 Timer1.Enabled = true; huifu1.BringToFront(); //回复次数 huifucishu = label8.Text = (Convert.ToInt32(label8.Text) + 1).ToString(); } catch (Exception) { MessageBox.Show("你日你妹,急啥急,还没加载完毕呢!"); } } #endregion #region 大量重复操作判断 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { //this.webBrowser1.ScriptErrorsSuppressed = true; if (webBrowser1.ReadyState < WebBrowserReadyState.Complete || webBrowser1.Url.ToString() == LastUrl) return; LastUrl = webBrowser1.Url.ToString(); //执行正常流程代码………… } private string _LastUrl; public string LastUrl { get { return _LastUrl; } set { _LastUrl = value; } } #endregion #region 网页正在加载、请勿操作 private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { label3.Text = "网页正在加载、请勿操作"; jishiqi1.Enabled = true; } //页面加载完成、可以操作了 private void timer1_Tick(object sender, EventArgs e) { if (webBrowser1.ReadyState == WebBrowserReadyState.Complete != webBrowser1.IsBusy == false) { label3.Text = "页面加载完成、可以操作了"; jishiqi1.Enabled = false; } } #endregion #region 按钮3.1秒结束不可点 private void timer2_Tick(object sender, EventArgs e) { button1.E