im making an account creator and for numerous reasons i want the program to fill in the form slowly, so it looks more human and also for other reasons, so for example if I have code like thisWebBrowser1.Document.GetElementById("iFirstName").Focus()
WebBrowser1.Document.GetElementById("iFirstName").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("iLastName").Focus()
WebBrowser1.Document.GetElementById("iLastName").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("iBirthDay").Focus()
WebBrowser1.Document.GetElementById("iBirthDay").SetAttribute("value", ComboBox2.Text)
WebBrowser1.Document.GetElementById("iBirthMonth").Focus()
WebBrowser1.Document.GetElementById("iBirthMonth").SetAttribute("value", ComboBox1.Text)
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
WebBrowser1.Document.GetElementById("iBirthYear").SetAttribute("value", ComboBox3.Text)
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
WebBrowser1.Document.GetElementById("iFirstName").Focus()
WebBrowser1.Document.GetElementById("iFirstName").SetAttribute("value", TextBox1.Text)
Timer2.Enabled = True
Timer1.Enabled = False
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
WebBrowser1.Document.GetElementById("iLastName").Focus()
WebBrowser1.Document.GetElementById("iLastName").SetAttribute("value", TextBox2.Text)
Timer3.Enabled = True
Timer2.Enabled = False
End Sub
Dim aRandomNumber As New Random() '' Used to generate random numbers (pseudo-random..)
WebBrowser1.Document.GetElementById("iFirstName").Focus()
WebBrowser1.Document.GetElementById("iFirstName").SetAttribute("value", TextBox1.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(1000,2000)) ''Get a random number between 1000 and 2000 (1 to 2 seconds)
WebBrowser1.Document.GetElementById("iLastName").Focus()
WebBrowser1.Document.GetElementById("iLastName").SetAttribute("value", TextBox2.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(1000,2000))
WebBrowser1.Document.GetElementById("iBirthDay").Focus()
WebBrowser1.Document.GetElementById("iBirthDay").SetAttribute("value", ComboBox2.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(1000,2000))
WebBrowser1.Document.GetElementById("iBirthMonth").Focus()
WebBrowser1.Document.GetElementById("iBirthMonth").SetAttribute("value", ComboBox1.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(1000,2000))
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
WebBrowser1.Document.GetElementById("iBirthYear").SetAttribute("value", ComboBox3.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(1000,2000)) 'maybe not needed here. ?
Dim aRandomNumber As New Random() '' Used to generate random numbers (pseudo-random..)
Dim minSleepTime as Int32 = 1000 '' in milliseconds, should be a const
Dim maxSleepTime as Int32 = 2000 '' in milliseconds, should be a const
WebBrowser1.Document.GetElementById("iFirstName").Focus()
WebBrowser1.Document.GetElementById("iFirstName").SetAttribute("value", TextBox1.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(minSleepTime ,maxSleepTime)) ''Get a random number between min and max
WebBrowser1.Document.GetElementById("iLastName").Focus()
WebBrowser1.Document.GetElementById("iLastName").SetAttribute("value", TextBox2.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(minSleepTime ,maxSleepTime))
WebBrowser1.Document.GetElementById("iBirthDay").Focus()
WebBrowser1.Document.GetElementById("iBirthDay").SetAttribute("value", ComboBox2.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(minSleepTime ,maxSleepTime))
WebBrowser1.Document.GetElementById("iBirthMonth").Focus()
WebBrowser1.Document.GetElementById("iBirthMonth").SetAttribute("value", ComboBox1.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(minSleepTime ,maxSleepTime))
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
WebBrowser1.Document.GetElementById("iBirthYear").SetAttribute("value", ComboBox3.Text)
Threading.Thread.Sleep(aRandomNumber.GetNext(minSleepTime ,maxSleepTime)) 'maybe not needed here. ?
Sub Wait(ByVal cTime As Long) Dim sTime As Long sTime = GetTickCount + cTime Do While sTime >= GetTickCount Application.DoEvents() Loop End Sub
Sub RunCode()
'Code here
End Sub
Dim T As System.Threading.Thread = New System.Threading.Thread(AddressOf RunCode)
T.Start()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Navigate("https://login.live.com")
TabControl1.SelectTab(1)
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.DocumentTitle = "Sign in to your Microsoft account" And WebBrowser1.Url.ToString.StartsWith("https://login.live.com/") Then
Hotmail.Enabled = True
End If
If WebBrowser1.DocumentTitle = "Sign up - Microsoft account" Then
Hotmail2.Enabled = True
End If
If WebBrowser1.DocumentTitle.ToString.StartsWith("Outlook - " + TextBox3.Text) Then
MsgBox("Your account has been successfully created and the details saved in the history tab")
End If
End Sub
Private Sub Hotmail_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hotmail.Tick
WebBrowser1.Document.GetElementById("idA_SignUp").Focus()
WebBrowser1.Document.GetElementById("idA_SignUp").InvokeMember("click")
Hotmail.Enabled = False
End Sub
Private Sub Hotmail2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hotmail2.Tick
Try
WebBrowser1.Document.GetElementById("iFirstName").Focus()
WebBrowser1.Document.GetElementById("iFirstName").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("iLastName").Focus()
WebBrowser1.Document.GetElementById("iLastName").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("iBirthDay").Focus()
WebBrowser1.Document.GetElementById("iBirthDay").SetAttribute("value", ComboBox2.Text)
WebBrowser1.Document.GetElementById("iBirthMonth").Focus()
WebBrowser1.Document.GetElementById("iBirthMonth").SetAttribute("value", ComboBox1.Text)
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
WebBrowser1.Document.GetElementById("iBirthYear").SetAttribute("value", ComboBox3.Text)
WebBrowser1.Document.GetElementById("imembernameeasi").Focus()
WebBrowser1.Document.GetElementById("imembernameeasi").SetAttribute("value", TextBox3.Text)
WebBrowser1.Document.GetElementById("iPwd").Focus()
WebBrowser1.Document.GetElementById("iPwd").SetAttribute("value", TextBox4.Text)
WebBrowser1.Document.GetElementById("iRetypePwd").Focus()
WebBrowser1.Document.GetElementById("iRetypePwd").SetAttribute("value", TextBox4.Text)
WebBrowser1.Document.GetElementById("iPhone").Focus()
WebBrowser1.Document.GetElementById("iPhone").SetAttribute("value", TextBox5.Text)
WebBrowser1.Document.GetElementById("iAltEmail").Focus()
WebBrowser1.Document.GetElementById("iAltEmail").SetAttribute("value", TextBox6.Text)
WebBrowser1.Document.GetElementById("iZipCode").Focus()
WebBrowser1.Document.GetElementById("iZipCode").SetAttribute("value", TextBox7.Text)
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
SendKeys.Send("{TAB}")
SendKeys.Send("{DOWN}")
Hotmail2.Enabled = False
MsgBox("Filling in the form has comepleted, please scroll to the bottom of the page and comeplete the captcha")
WebBrowser1.Document.GetElementById("iBirthYear").Focus()
SendKeys.Send("{TAB}")
SendKeys.Send("{DOWN}")
Hotmail2.Enabled = False
Catch ex As Exception
Hotmail2.Enabled = False
MsgBox("something went wrong the form was unable to be comepleted")
Hotmail2.Enabled = False
End Try
End Sub
private declare sub sleep lib "kernel32" (byval dwMilliseconds as long) sleep(1000)