所以我一直在努力解決這個問題很長一段時間了。我試圖找出如何啓用計時器,並在網頁加載完成後將間隔設置爲1000。C#等待瀏覽器芬蘭語加載然後啓動一個計時器
這裏是代碼我已經試過到目前爲止:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("website.com");
webBrowser1.ScriptErrorsSuppressed = true;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("brukernavn")[0].SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("passord")[0].SetAttribute("value", textBox2.Text);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("login_buton")[0].InvokeMember("click");
timer1.Enabled = true;
timer1.Interval = 7000;
}
private void timer1_Tick(object sender, EventArgs e)
{
webBrowser1.Navigate("website.com/mygambling.php");
//Here i need a code to enable timer2 whit interval 1000 when the website is finnished loading
}
private void timer2_Tick(object sender, EventArgs e)
{
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("bet")[0].SetAttribute("value", 250);
webBrowser1.Document.GetElementsByTagName("input").GetElementsByName("start")[0].InvokeMember("click");
}
}
}
所以我的問題是我如何可以啓用定時器,當頁面完成加載定時器的時間間隔設置爲1000?
您處理[WebBrowser.DocumentCompleted(https://msdn.microsoft.com/en-us/library/system.windows.forms。 webbrowser.documentcompleted(v = vs.110)的.aspx)? – GSerg