[C#] 纯文本查看 复制代码 private Form1 f1;
System.Timers.Timer tt = new System.Timers.Timer(5000 * 1);
public Form2()
{
InitializeComponent();
}
public Form2(Form1 f)
{
InitializeComponent();
f1 = f;
}
private void Form2_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(Myset.Default.Lurl);
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.IsBusy == false)
{
HtmlElement btn = webBrowser1.Document.GetElementById("J_SubmitQuick");
if (btn != null)
{
tt.Elapsed += new System.Timers.ElapsedEventHandler(ThreadStartExe);
tt.AutoReset = true;
tt.Enabled = true;
tt.Start();
}
}
}
private void ThreadStartExe(object source, System.Timers.ElapsedEventArgs e)
{
try
{
webBrowser1.Invoke(new ThreadStart(delegate
{
Application.DoEvents();
HtmlElement btn1 = webBrowser1.Document.GetElementById("J_SubmitQuick");
btn1.InvokeMember("click");
tt.AutoReset = false;
tt.Enabled = false;
tt.Close();
}));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
}
|