using System; using System.Drawing; using System.Windows.Forms; namespace hiddenBrowser { public partial class hiddenBrowserForm : Form { Uri Url; bool firstFlag = false; const int maxCount = 10; int updateCount = maxCount; public String firstString { get; set; } public hiddenBrowserForm(String url) { InitializeComponent(); firstString = ""; Url = new Uri(url); Hide(); } private void Form1_Shown(object sender, EventArgs e) { webBrowser1.ScriptErrorsSuppressed = true; webBrowser1.Url = Url; firstFlag = true; timer2.Enabled = true; } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (true == firstFlag) { firstString = webBrowser1.Document.Body.OuterHtml; timer1.Enabled = true; } } private void timer1_Tick(object sender, EventArgs e) { if ((null != webBrowser1.Document) && (null != webBrowser1.Document.Body)) { String s = webBrowser1.Document.Body.OuterHtml; updateCount--; if (firstString != s) { firstString = s; updateCount = maxCount; } } if (0 == updateCount) { Close(); } } private void timer2_Tick(object sender, EventArgs e) { if ((null != webBrowser1.Document) && (null != webBrowser1.Document.Body)) { firstString = webBrowser1.Document.Body.OuterHtml; } Close(); } } }