I have a script that logs into a website and can autoclick something very fast for the given interval. Now ever since I added my newest detail in, everything in the script works, except the autoclicker. Once I click the button to start the autoclicker it doesn't even click once.
Here is the code I just added
With WebBrowser1
Do Until Not (.IsBusy)
Application.DoEvents()
Loop
Do Until .ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop
End With
Dim htmlText As String
If Not (WebBrowser1.Document.Body.InnerHtml) Is Nothing Then
htmlText = WebBrowser1.Document.Body.InnerHtml
If InStr(htmlText, "Microsoft account") Then
MessageBox.Show("You have entered in a wrong password or the account doesn't exist.")
'code to go here if it is true
Else
MessageBox.Show("Sign in successful. Proceed on...")
'code to go here if it is false
End If
End If
what the code does is it tells you if you used the correct login credentials or the wrong ones. But i don't understand how that would affect my autoclicking button?
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
Timer1.Interval = 40
ElseIf RadioButton2.Checked = True Then
Timer1.Interval = 100
Else
Timer1.Interval = 500
End If
Timer1.Start()
WebBrowser1.Document.GetElementById("NewGamertag").SetAttribute("value", txtTurbo.Text)
WebBrowser1.Document.GetElementById("claimIt").InvokeMember("Click")
End Sub
Where timer1 =
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WebBrowser1.Document.GetElementById("claimIt").InvokeMember("Click")
End Sub
Make your timer1.enable = true, else it wont be work.
Related
I'm trying to connect to a database (mdb file of my choice) in a login screen and i want to save it for faster logon next times i boot the software.
I click on choose database button, opendialog lets me choose the file, i click OK and the db location shows in a textbox.
there's a checkbox beneath to save it before i connect to it.
But i can't manage to keep the checkbox checked, nor the textbox filled after i restart te program.
here's my current code:
Public Class LoginScreen
Private Sub Loginscreen_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar2.Minimum = 0
ProgressBar2.Maximum = 100
ProgressBar2.Visible = False
Panel1.Visible = False
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Application.Exit()
End Sub
Private Sub btnExit2_Click(sender As Object, e As EventArgs) Handles btnExit2.Click
Application.Exit()
End Sub
Private Sub tmrLogin_Tick(sender As Object, e As EventArgs) Handles tmrLogin.Tick
ProgressBar2.Value = ProgressBar2.Value + 20
lblLoginMessages.Text = ProgressBar2.Value & "%" & " Completed"
If ProgressBar2.Value >= 100 Then
tmrLogin.Enabled = False
If txtUser.Text = "azert" And txtPassword.Text = "azert" Then
ProgressBar2.Value = 0
Else
lblLoginMessages.Text = "Wrong credentials, Try again!"
pboxClosed.Visible = True
PboxOpen.Visible = False
ProgressBar2.Value = 0
txtPassword.Text = ""
txtUser.Text = ""
End If
End If
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
ProgressBar2.Visible = True
tmrLogin.Enabled = True
pboxClosed.Visible = False
PboxOpen.Visible = True
''navraag doen om dit correct in te stellen! ! ! ! !!
'If ProgressBar2.Value = 100 Then
'lblLoginMessages.Text = "Logging in..."
Me.Hide()
Mainscreen.Show()
'End If
If chkSavePassword.Checked = True Then
My.Settings.databaselocation = txtDatabaselocationshow.Text
My.Settings.SaveLocation = True
End If
End Sub
Private Sub btnDBConnect_Click(sender As Object, e As EventArgs) Handles btnDBConnect.Click
If Panel1.Visible = False Then
Panel1.Visible = True
Else
Application.Exit()
End If
End Sub
Private Sub btnChoose_Click(sender As Object, e As EventArgs) Handles btnChoose.Click
Dim strtext As String
OpenFileDialog1.Filter = "Database Files | *.mdb"
OpenFileDialog1.InitialDirectory = "F:\GoogleDrive\EINDWERK VBNET"
OpenFileDialog1.Title = "Choose your Database"
OpenFileDialog1.ShowDialog()
strtext = OpenFileDialog1.FileName
txtDatabaselocationshow.Text = strtext
'If OpenFileDialog1.ShowDialog = DialogResult.OK Then
' strtext = OpenFileDialog1.FileName
' txtDatabaselocationshow.Text = strtext
'Else
' MsgBox("Error: the database file could not be read, try again.")
'End If
End Sub
Private Sub tmrshowloginpanel_Tick(sender As Object, e As EventArgs) Handles tmrshowloginpanel.Tick
Panel1.Width += 5
If Panel1.Width >= 700 Then
tmrshowloginpanel.Stop()
End If
End Sub
End Class
i've scoured the net but can't really find what to do?
if you need more information, shoot!
Walk through this with me:
Make a new project, one form, add a textbox and a combobox.
Click the textbox:
In the properties grid at the top click (Application Settings), then the 3 dots next to Property Binding. Scroll to Text. Drop down the setting and choose New at the bottom.
Give it a name of ChosenDatabasePath or something useful and descriptive like that
Repeat from "Click the textbox" for the checkbox instead, and this time bind the Checked property not the Text property.. Call the checkbox's Checked binding SavePassword or similar
Close all the dialogs so you're back at the form
Click anywhere on the background of the form when switch to Events in the property grid, find FormClosing and double click it
Put My.Settings.Save() in the FormClosing event handler
Run the app, write something in the textbox, close the form (by the X, not by stopping debugging), then immediately open the app again (run it)
I'm trying to make it so when the button is pressed, it disables the button and allows you to select the mouse coordinates. (With right click) then enable back the button. How do you detect if button1 was pressed for the if statement while keeping the timer?
If Button1.clicked Then
This is where I need the If statement to detect button1 being pressed.
Private Sub Timer2_Tick(sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Button1.clicked Then
Button1.Enabled = False
If GetAsyncKeyState(2) Then
TextBox1.Text = Cursor.Position.X
TextBox2.Text = Cursor.Position.Y
Button1.Enabled = True
End If
End If
End Sub
Thanks with the help of #the_lotus I found a way around the timer/button issue.
Instead of looking for the button press within the timer statement, you control if the timer is on or off.
Lotus also asked for the reasoning behind the timer. The timer is so the form always looks for a input, not just when the button is pressed.
Private Sub Button1_Click(sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
Timer2.Interval = 5
Timer2.Enabled = True
Me.Button1.Text = "Set Posistion 1"
End Sub
Sub Timer2_Tick() Handles Timer2.Tick
If GetAsyncKeyState(2) Then
TextBox1.Text = Cursor.Position.X
TextBox2.Text = Cursor.Position.Y
Button1.Enabled = True
Timer2.Enabled = False
Me.Button1.Text = "Reset Position"
End If
End Sub
I have 2 forms in my project. Users cannot exit from the first from, frmOptometry. I have this implemented this way:
Private Sub frmOptometry_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
MessageBox.Show("You can only close the application from the receipt screen!")
e.Cancel = True
End Sub
The second form, frmReceipt can be exited from. I have it implemented this way:
Private Sub frmReceipt_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MessageBox.Show("Are you sure you want to quit?",
"Obi-Wan Optometry Closing",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) =
DialogResult.No Then
e.Cancel = True
Else
frmOptometry.Close()
End If
End Sub
Right now, it does not close the program completely because it goes to the frmOptometry_FormClosing and prevents it. What should I do to fix this? Is there anyway to figure out where the user is trying to shut down the program and then decide from there?
One way to solve this is by introducing a flag (say, called FromReceipt) which indicates who asks the frmOptometry to close itself.
Something like this on frmOptometry will do:
Public FromReceipt As Boolean = False 'Add this
Private Sub frmOptometry_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If Not FromReceipt Then 'add this condition
MessageBox.Show("You can only close the application from the receipt screen!")
e.Cancel = True
End If
End Sub
And then on the frmReceipt:
Private Sub frmReceipt_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If MessageBox.Show("Are you sure you want to quit?",
"Obi-Wan Optometry Closing",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) =
DialogResult.No Then
e.Cancel = True
Else
frmOptometry.FromReceipt = True 'Add this line to tell the frmOptometry: this time you can really close it
frmOptometry.Close()
End If
End Sub
I'm experimenting with a simple auto typer. I've made several of these before, but have never received this error. I just want to be able to send the text within textbox3 to the currently focused window. Here's the code :
code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Timer1.Enabled = False Then
Timer1.Enabled = True
Button2.Text = "Stop"
ElseIf Timer1.Enabled = True Then
Timer1.Enabled = False
Button2.Text = "Send"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If CheckBox1.Checked = True Then
SendKeys.Send("{ENTER}")
SendKeys.Send(TextBox3.Text)
ElseIf CheckBox1.Checked = False Then
SendKeys.Send(TextBox3.Text)
End If
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
Timer1.Interval = NumericUpDown1.Value
End Sub
Thats the only portion involving the sendkeys method and timer. Some of the text within textbox3 comes from variables as well, if that helps to know.
In another (now deleted) question, you claim the error happens here:
SendKeys.Send(Textbox3.Text)
Well, what is the value of Textbox3.Text which produces the error? According to the documentation, specifying repeated keys would involve a key token and an integer separate by a space, enclosed in curly braces. Something like "{LEFT 42}" or "{h 10}". So if you're entering something like "{A B}" then it's going to fail.
Presumably the runtime value of Textbox3.Text has an invalid format for SendKeys.Send(), or is mis-using characters which are otherwise reserved for the format string.
I have created an autoclicker that once someone hits a button, it sends requests to the submit button on a page to be clicked about once a second. It works great, and lasts about 30 minutes, but it still times and becomes unresponsive. The current script I'm working with seems good:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
Timer1.Interval = 40
ElseIf RadioButton2.Checked = True Then
Timer1.Interval = 100
Else
Timer1.Interval = 500
End If
If ((WebBrowser1.IsBusy)) Then
Else
WebBrowser1.Document.GetElementById("NewGamertag").SetAttribute("value", txtTurbo.Text)
Timer1.Enabled = True
End If
End Sub
Where Timer1 has the code to autoclick the submit button:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WebBrowser1.Document.GetElementById("claimIt").InvokeMember("Click")
End Sub
So now I need to know how to refresh it every X seconds. I created a new timer called RefreshPage, and gave it these principals:
Private Sub RefreshPage_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshPage.Tick
WebBrowser1.Refresh()
End Sub
The only problem is, now when I enable RefreshPage (RefreshPage.Enabled = True) in my Button1, it tells me this: http://gyazo.com/4c9f83a48d6262b26757281512bee35c
I have no idea what this means or how to fix it, my best guess is that it tries to refresh as it tries to claim thus meaning the button is not findable in the source. (Right when I open the program and press the button the program becomes unresponsive)
Any help?