Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Size = New Size(640, 480)
Me.Show()
Dim WebBrowser1 As New WebBrowser
WebBrowser1.Size = New Size(630, 444)
Me.Controls.Add(WebBrowser1)
WebBrowser1.Anchor = 15
Me.WindowState = FormWindowState.Maximized
WebBrowser1.Navigate("https://mail.google.com/")
Me.Text = "Waiting for page to load..."
While WebBrowser1.IsBusy = True
Application.DoEvents()
End While
While (WebBrowser1.ReadyState <> WebBrowserReadyState.Complete)
Application.DoEvents()
End While
While IsNothing(WebBrowser1.Document) = True
Application.DoEvents()
End While
Me.Text = "Waiting for Username textbox to load..."
While IsNothing(WebBrowser1.Document.GetElementById("Email")) = True
Application.DoEvents()
End While
Me.Text = "Supplying username."
WebBrowser1.Document.GetElementById("Email").SetAttribute("value", "Replace this with the username.")
Me.Text = "Waiting for Password textbox to load..."
While IsNothing(WebBrowser1.Document.GetElementById("Passwd")) = True
Application.DoEvents()
End While
Me.Text = "Supplying password."
WebBrowser1.Document.GetElementById("Passwd").SetAttribute("value", "Replace this with the password.")
Me.Text = "Waiting for Submit button to load..."
While IsNothing(WebBrowser1.Document.GetElementById("signin")) = True
Application.DoEvents()
End While
Me.Text = "Clicking Submit button."
WebBrowser1.Document.GetElementById("signin").InvokeMember("click")
Me.Text = "Logged on."
End Sub
Tips and tricks for .NET using ASP and VB code.
Automatically log on to a website.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment