110,571
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace 测试I
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(Open));
t.Start();
}
private void Open()
{
wb.Navigate("http://baidu.com");
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wbe_Auto);
}
private void wbe_Auto(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
HtmlElement tmp = wb.Document.All["kw"];
wb.Document.All["subject"].SetAttribute("value", "aaaa");
}
catch (Exception ex)
{
txb.Text = ex.ToString();
}
}
}
}
while(wb.IsBusy){Thread.Sleep(1000);}