|
代码就不隐藏了 需要的自己看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace 贴吧自动回帖工具
{
public partial class Form1 : Form
{
string yuanma = string.Empty;
int number = 1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.Navigate(textBox1 .Text);
try
{
if (button1.Text =="开始回复")
{
timer1.Interval = int.Parse(textBox3.Text)*1000;
timer1.Enabled = true;
button1.Text = "停止回复";
}
else
{
timer1.Enabled = false;
button1.Text = "开始回复";
}
}
catch
{
MessageBox.Show("请输出正确数字好么骚年");
timer1.Enabled = false;
}
//登录百度
//屏蔽ing
}
private void send()
{
if (comboBox1.Text == "发帖")
{
HtmlElement html_input = webBrowser1.Document.All["title"];
html_input.InvokeMember("click");
html_input.SetAttribute("value", "q1101234");
html_input = webBrowser1.Document.All["ueditor_replace"];
html_input.InvokeMember("click");
html_input.InnerHtml = "<p>" + textBox2.Text + "</p>";
HtmlDocument document = this.webBrowser1.Document;//获取控件中的html文档,类似于网页中的document对象。
HtmlElementCollection elems = webBrowser1.Document.GetElementsByTagName("a");//根据标签<a>来遍历元素。
foreach (HtmlElement em in elems) //遍历所有元素
{
if (em.GetAttribute("title") == "Ctrl+Enter快捷发表") //根据title来匹配,因为加关注只有一个按钮
{
em.InvokeMember("click");
this.Text = "已发布N个回复:" + number;
number++;
}
}
}
else
{
HtmlElement html_input = webBrowser1.Document.All["ueditor_replace"];
html_input.InvokeMember("click");
html_input.InnerHtml = "<p>" + textBox2.Text + "</p>";
HtmlDocument document = this.webBrowser1.Document;//获取控件中的html文档,类似于网页中的document对象。
HtmlElementCollection elems = webBrowser1.Document.GetElementsByTagName("a");//根据标签<a>来遍历元素。
foreach (HtmlElement em in elems) //遍历所有元素
{
if (em.GetAttribute("title") == "Ctrl+Enter快捷发表") //根据title来匹配,因为加关注只有一个按钮
{
em.InvokeMember("click");
this.Text = "已发布N个回复:" + number;
number++;
}
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
send();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(comboBox1 .Text=="回复")
textBox4.Enabled = false;
else
textBox4.Enabled = true;
}
}
} |
|