![C# webbrowser文本框的键盘和鼠标模拟输入和模拟鼠标点击](https://1200zi.500zi.com/uploadfile/img/15/275/21ec589ef9e84163e231a3cab0074ad5.jpg)
模拟输入:
第一种方法:
private void button1_Click(object sender, EventArgs e)
{
//来做测试
HtmlDocument doc = this.webBrowser1.Document;
HtmlElement keyword= doc.GetElementById("kw");
keyword.Focus(); //焦点请求,这个必须要
string customeString = "天涯明月刀";
SendKeys.Send(zhidingstring);
System.Threading.Thread.Sleep(100);
SendKeys.Flush();
}
第二种方法:
private void button1_Click(object sender, EventArgs e)
{
//来做测试
HtmlDocument doc = this.webBrowser1.Document;
HtmlElement keyword = doc.GetElementById("kw");
keyword.InnerText = "冰川时代";
}
=====================================================
模拟鼠标点击
第一种方法:
private void button9_Click(object sender, EventArgs e)
{
//来做测试
HtmlDocument doc = this.webBrowser1.Document;
doc.GetElementById("su").InvokeMember("click");
}
第二种方法:
winfrom 设置 窗体属性 Acceptbutton 为button9