i was trying to make a free microsoft word plugin in vb.net. It automatically fills a web form. The main problem with the plugin is that it uses web browser control and once it has filled a form it will need to navigate another form. The form can only be filled once it has completely been loaded.
so my approach is
1. navigate to first site when form loads
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://google.com")
End Sub
2. use an integer i and use if statements to check which form to fill :
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If (i = 1) Then
WebBrowser1.Document.GetElementById("username").SetAttribute("value", "elvin")
WebBrowser1.Document.GetElementById("password").SetAttribute("value", "1111111")
WebBrowser1.Document.GetElementById("wpt").InvokeMember("click")
i = 2
ElseIf (i = 2) Then
WebBrowser1.Document.GetElementById("title").SetAttribute("value", "elvin")
WebBrowser1.Document.GetElementById("content").SetAttribute("value", "111111")
WebBrowser1.Document.GetElementById("tags").SetAttribute("value", "fgddferre")
WebBrowser1.Document.GetElementById("publish").InvokeMember("click")
i = 3
Timer1.Start()
ElseIf (i = 3) Then
Timer1.Stop()
WebBrowser1.Document.GetElementById("loginTextBlock_uname").SetAttribute("value", "elvin")
WebBrowser1.Document.GetElementById("loginTextBlock").SetAttribute("value", "11111")
WebBrowser1.Document.GetElementById("nowwhat").InvokeMember("click")
i = 4
ElseIf (i = 4) Then
WebBrowser1.Document.GetElementById("title").SetAttribute("value", "elvin")
WebBrowser1.Document.GetElementById("content").SetAttribute("value", "11111")
WebBrowser1.Document.GetElementById("tags").SetAttribute("value", "fghfghfgh")
WebBrowser1.Document.GetElementById("publish").InvokeMember("click")
i = 5
Timer1.Start()
ElseIf (i = 5) Then
WebBrowser1.Document.GetElementById("user").SetAttribute("value", "rfgjhfhj")
WebBrowser1.Document.GetElementById("pass").SetAttribute("value", "566788989")
WebBrowser1.Document.GetElementById("wpt").InvokeMember("click")
i = 6
End If
End Sub
3. this is the main step. you see when main form loads, i=1 so browser goes to google.com (first form), when form is completely loaded, itchecks for value of i. Since i=1, it fills google. After filling and continuing i=2 and browser goes to my personal account page. This means browser again loads the document. Now i=2, so it fills my personal detalis. Now the timer starts. Since i=3, browser navigates to second site and fills the details.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (i = 3) Then
WebBrowser1.Navigate("http://blogger.com")
ElseIf (i = 5) Then
WebBrowser1.Navigate("http://www.yahoo.com/")
End If
End Sub
now the problem arises. The browser does not go to the third site. Once the timer has been stopped and started, the following code does not goto the elseif part (i.e. i=5) why is that so?