AutoClicker - Mouse Cursor Position [VB.net 2008]
Hi! :)
I've been programming for about 1 month, and i'm making an AutoClicker at the moment. The AutoClicker works fine, but i can't figure out have to get the Mouse Cursor Position system. I've searched about have to get one but i can't find anything for Visual Basic 2008 Express Edition.
I hope you understand what i'm talking about but here is another explanation:
My AutoClicker have to locate the point you want to Click, which means if the AutoClicker fall out of the Position that have been chosen it goes straight back.
I need this in Visual Basic 2008 Express Edition.
Yeah, I'm not english.
Thanks!:) :)
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
vb Code:
MsgBox(Cursor.Position.ToString)
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Didn't work, think the code is a bit bigger than that :)
We need the X & Y-ax i think.
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Cursor.Position.X
Cursor.Position.Y
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Thanks again, mate :)
But i don't got very much "Experience" in VB.net so i need someone
to make an example of whole code.
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
post the code you've done so far
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
VB CODE:
Quote:
Imports System.Deployment.Application
Public Class Form1
Private ClicksPerSecond As Integer = 10
Public Running As Boolean
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, ByVal dwextrainfo As Long)
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer2.Enabled = True
If TextBox1.Text = "" Then
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End If
If Button1.Enabled = True Then
TextBox1.Enabled = False
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim clickrate As Double
Dim OriginalPoint As Point
OriginalPoint = System.Windows.Forms.Cursor.Position
Running = True
If GetAsyncKeyState(Keys.F2) Then
Me.Refresh()
End If
If RadioButton1.Checked Then
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Else
If RadioButton2.Checked Then
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End If
End If
If Double.TryParse(TextBox1.Text, clickrate) Then
clickrate = Math.Round(clickrate, 1)
If clickrate > 0 Then
If IsNumeric(TextBox1.Text) Then
Timer1.Interval = 1000 / clickrate
Timer2.Interval = 1000 / clickrate
If RadioButton1.Checked And Button1.Enabled And clickrate >= 0.1 Then
Timer1.Enabled = True
Else
If RadioButton2.Checked And Button1.Enabled And clickrate >= 0.1 Then
Timer2.Enabled = True
End If
End If
End If
End If
End If
Timer3.Enabled = True
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
'#LineUs#
Timer3.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer2.Stop()
Timer1.Enabled = False
Timer2.Enabled = False
TextBox1.Enabled = True
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If RadioButton1.Checked And GetAsyncKeyState(Keys.F1) Then
Timer1.Enabled = True '#1#
Else
If RadioButton1.Checked And GetAsyncKeyState(Keys.F2) Then
Timer1.Enabled = False '#1#
Else
If RadioButton2.Checked And GetAsyncKeyState(Keys.F1) Then
Timer2.Enabled = True '#2"
If RadioButton2.Checked And GetAsyncKeyState(Keys.F2) Then
Timer2.Enabled = False '#2#
If RadioButton1.Checked And GetAsyncKeyState(Keys.F3) Then
Timer1.Enabled = False
Timer2.Enabled = False
Me.Close()
End If
End If
End If
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer3.Enabled = True
If GetAsyncKeyState(Keys.F1) Then
Timer1.Enabled = True
If GetAsyncKeyState(Keys.F2) Then
Timer1.Enabled = False
End If
End If
End Sub
End Class
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
the parameters - 'ByVal dx As Long, ByVal dy As Long' in mouse_event refer to where to click.
you should use code tags when you post code
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
what do you want it to click?
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Quote:
Originally Posted by .paul.
what do you want it to click?
I want it to click on the chosen point.
"Maybe: A button named Set Cursor Position, by clicking on this button you click on the screen then it starts clicking on the chosen point."
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
something like this will do the job
vb Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim clickrate As Double
Dim OriginalPoint As Point
OriginalPoint = System.Windows.Forms.Cursor.Position
Running = True
If GetAsyncKeyState(Keys.F2) Then
Me.Refresh()
End If
If RadioButton1.Checked Then
mouse_event(MOUSEEVENTF_LEFTDOWN, OriginalPoint.X, OriginalPoint.Y, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, OriginalPoint.X, OriginalPoint.Y, 0, 0)
ElseIf RadioButton2.Checked Then
mouse_event(MOUSEEVENTF_RIGHTDOWN, OriginalPoint.X, OriginalPoint.Y, 0, 0)
mouse_event(MOUSEEVENTF_RIGHTUP, OriginalPoint.X, OriginalPoint.Y, 0, 0)
End If
If Double.TryParse(TextBox1.Text, clickrate) Then
clickrate = Math.Round(clickrate, 1)
If clickrate > 0 Then
If IsNumeric(TextBox1.Text) Then
Timer1.Interval = 1000 / clickrate
Timer2.Interval = 1000 / clickrate
If RadioButton1.Checked And Button1.Enabled And clickrate >= 0.1 Then
Timer1.Enabled = True
ElseIf RadioButton2.Checked And Button1.Enabled And clickrate >= 0.1 Then
Timer2.Enabled = True
End If
End If
End If
End If
Timer3.Enabled = True
End Sub
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
I didn't get it to work, but i got an idea!
Look here: http://www.geocities.com/mangokun/au...useclicker.htm
As you can see in the picture: "Locate" and X-Y-ax .. is there any way to get it like this?
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
heres an example of how to capture mouseclicks outside of your form
http://www.vbforums.com/showthread.php?t=358556
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Could u send me a picture of the Form Design? I also wanna make an autoclicker but i dont know which items to use XD
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Imports System.Threading
Public Class Form1
Dim eventon1 As Integer = 0
Dim eventcount As Integer = 0
Dim timeleft As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = True
CheckBox5.Checked = False
CheckBox5.Enabled = False
Button3.Enabled = False
Timer1.Interval = 500
TextBox31.Text = "60"
TextBox31.ReadOnly = True
TextBox1.Text = "947"
TextBox2.Text = "-232"
TextBox3.Text = "4000"
TextBox4.Text = "6000"
TextBox5.Text = "10000"
TextBox6.Text = "8000"
TextBox7.Text = "-206"
TextBox8.Text = "960"
TextBox9.Text = "45000"
TextBox10.Text = "38000"
TextBox11.Text = "-392"
TextBox12.Text = "1022"
TextBox13.Text = "10"
TextBox20.Text = "1043"
TextBox19.Text = "-317"
TextBox24.Text = "1000"
TextBox23.Text = "-407"
TextBox28.Text = "956"
TextBox27.Text = "-244"
TextBox26.Text = "1010"
TextBox25.Text = "-174"
TextBox18.Text = "955"
TextBox17.Text = "-423"
TextBox22.Text = "1043"
TextBox21.Text = "-504"
Timer4.Interval = CInt(TextBox31.Text) * 1000 * 60
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim MousePosition As Point
MousePosition = Cursor.Position
TextBox14.Text = MousePosition.X
TextBox15.Text = MousePosition.Y
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
timeleft = timeleft - 500
TextBox30.Text = timeleft.ToString
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
KillHungProcess("HD-Player.exe")
KillHungProcess("BstkSVC.exe")
Thread.Sleep(10000)
Shell("cmd.exe /k " + """C:\Program Files\BlueStacks_nxt\HD-Player.exe"" --instance Nougat32 --cmd launchApp --package com.addictive.strategy.army")
Thread.Sleep(60000)
Windows.Forms.Cursor.Position = New Point(887, 83)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Thread.Sleep(5000)
Dim x3 As Integer = CInt(TextBox12.Text)
Dim y3 As Integer = CInt(TextBox11.Text)
Windows.Forms.Cursor.Position = New Point(x3, y3)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
End Sub
Public Sub KillHungProcess(processName As String)
Dim psi As ProcessStartInfo = New ProcessStartInfo
psi.Arguments = "/im " & processName & " /f"
psi.FileName = "taskkill"
Dim p As Process = New Process()
p.StartInfo = psi
p.Start()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If eventon1 = 1 Then
Dim x1 As Integer = CInt(TextBox1.Text)
Dim y1 As Integer = CInt(TextBox2.Text)
Windows.Forms.Cursor.Position = New Point(x1, y1)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
ElseIf eventon1 = 2 Then
Dim x2 As Integer = CInt(TextBox8.Text)
Dim y2 As Integer = CInt(TextBox7.Text)
Windows.Forms.Cursor.Position = New Point(x2, y2)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
ElseIf eventon1 = 3 Then
Dim x3 As Integer = CInt(TextBox12.Text)
Dim y3 As Integer = CInt(TextBox11.Text)
Windows.Forms.Cursor.Position = New Point(x3, y3)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
If CheckBox1.Checked = True Then
Windows.Forms.Cursor.Position = New Point(CInt(TextBox20.Text), CInt(TextBox19.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Windows.Forms.Cursor.Position = New Point(CInt(TextBox24.Text), CInt(TextBox23.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Windows.Forms.Cursor.Position = New Point(CInt(TextBox28.Text), CInt(TextBox27.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Windows.Forms.Cursor.Position = New Point(CInt(TextBox26.Text), CInt(TextBox25.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Windows.Forms.Cursor.Position = New Point(CInt(TextBox22.Text), CInt(TextBox21.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Windows.Forms.Cursor.Position = New Point(CInt(TextBox18.Text), CInt(TextBox17.Text))
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
End If
End If
TextBox16.AppendText(DateAndTime.Now.ToString + ": clicked." + Environment.NewLine)
Timer2.Stop()
eventon1 = eventon1 + 1
If eventon1 = 4 Then
eventcount = eventcount + 1
TextBox29.Text = (CInt(TextBox13.Text) - eventcount).ToString
If eventcount = CInt(TextBox13.Text) Then
TextBox16.AppendText(DateAndTime.Now.ToString + ": finished." + Environment.NewLine)
Else
eventon1 = 1
Call set1()
End If
ElseIf eventon1 = 2 Then
Call set2()
ElseIf eventon1 = 3 Then
Call set3()
End If
End Sub
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each t As TextBox In Me.Controls.OfType(Of TextBox)()
t.ReadOnly = True
Next
eventon1 = 1
eventcount = 0
Timer4.Interval = CInt(TextBox31.Text) * 1000 * 60
If CheckBox5.Checked = True Then Timer4.Start()
TextBox29.Text = (CInt(TextBox13.Text) - eventcount).ToString
Call set1()
End Sub
Sub set1()
Dim min1 As Integer = CInt(TextBox3.Text)
Dim max1 As Integer = CInt(TextBox4.Text)
Dim rnd = New Random()
Dim set1 = CInt(TextBox13.Text)
Dim interval1 = rnd.Next(min1, max1)
TextBox16.AppendText(DateAndTime.Now.ToString + ": " + interval1.ToString + Environment.NewLine)
Timer2.Interval = interval1
timeleft = interval1
Timer2.Start()
Timer3.Interval = 500
Timer3.Start()
End Sub
Sub set2()
Dim min2 As Integer = CInt(TextBox6.Text)
Dim max2 As Integer = CInt(TextBox5.Text)
Dim rnd = New Random()
Dim interval1 = rnd.Next(min2, max2)
TextBox16.AppendText(DateAndTime.Now.ToString + ": " + interval1.ToString + Environment.NewLine)
Timer2.Interval = interval1
timeleft = interval1
Timer2.Start()
Timer3.Interval = 500
Timer3.Start()
End Sub
Sub set3()
Dim min3 As Integer = CInt(TextBox10.Text)
Dim max3 As Integer = CInt(TextBox9.Text)
Dim rnd = New Random()
Dim interval1 = rnd.Next(min3, max3)
Timer2.Interval = interval1
TextBox16.AppendText(DateAndTime.Now.ToString + ": " + interval1.ToString + Environment.NewLine)
timeleft = interval1
Timer2.Start()
Timer3.Interval = 500
Timer3.Start()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
For Each t As TextBox In Me.Controls.OfType(Of TextBox)()
If t.Name = TextBox29.Name Then
ElseIf t.Name = TextBox30.Name Then
ElseIf t.Name = TextBox14.Name Then
ElseIf t.Name = TextBox15.Name Then
ElseIf t.Name = TextBox16.Name Then
Else
t.ReadOnly = False
End If
Next
eventon1 = 0
eventcount = 0
Timer2.Stop()
Timer3.Stop()
Timer4.Stop()
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
Timer1.Start()
End If
If CheckBox2.Checked = False Then
Timer1.Stop()
TextBox14.Text = ""
TextBox15.Text = ""
End If
End Sub
Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
CheckBox4.Checked = False
TextBox1.Text = "947"
TextBox2.Text = "-232"
TextBox3.Text = "4000"
TextBox4.Text = "6000"
TextBox5.Text = "10000"
TextBox6.Text = "8000"
TextBox7.Text = "-206"
TextBox8.Text = "960"
TextBox9.Text = "45000"
TextBox10.Text = "38000"
TextBox11.Text = "-392"
TextBox12.Text = "1022"
TextBox13.Text = "10"
TextBox20.Text = "1043"
TextBox19.Text = "-317"
TextBox24.Text = "1000"
TextBox23.Text = "-407"
TextBox28.Text = "956"
TextBox27.Text = "-244"
TextBox26.Text = "1010"
TextBox25.Text = "-174"
TextBox18.Text = "955"
TextBox17.Text = "-423"
TextBox22.Text = "1043"
TextBox21.Text = "-504"
ElseIf CheckBox3.Checked = False Then
CheckBox4.Checked = True
End If
End Sub
Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
CheckBox3.Checked = False
TextBox1.Text = "633"
TextBox2.Text = "546"
TextBox3.Text = "4000"
TextBox4.Text = "6000"
TextBox5.Text = "10000"
TextBox6.Text = "8000"
TextBox7.Text = "557"
TextBox8.Text = "623"
TextBox9.Text = "45000"
TextBox10.Text = "38000"
TextBox11.Text = "500"
TextBox12.Text = "704"
TextBox13.Text = "10"
TextBox20.Text = "639"
TextBox19.Text = "535"
TextBox24.Text = "703"
TextBox23.Text = "535"
TextBox28.Text = "635"
TextBox27.Text = "459"
TextBox26.Text = "690"
TextBox25.Text = "453"
TextBox18.Text = "690"
TextBox17.Text = "471"
TextBox22.Text = "686"
TextBox21.Text = "513"
ElseIf CheckBox4.Checked = False Then
CheckBox3.Checked = True
End If
If CheckBox3.Checked = True Then
CheckBox5.Enabled = False
TextBox31.ReadOnly = True
CheckBox5.Checked = False
Button3.Enabled = False
Else
CheckBox5.Enabled = True
TextBox31.ReadOnly = False
Button3.Enabled = True
End If
End Sub
Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Application.Restart()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If Timer4.Enabled = True Then
Timer4.Stop()
KillHungProcess("HD-Player.exe")
KillHungProcess("BstkSVC.exe")
Thread.Sleep(10000)
Shell("cmd.exe /k " + """C:\Program Files\BlueStacks_nxt\HD-Player.exe"" --instance Nougat32 --cmd launchApp --package com.addictive.strategy.army")
Thread.Sleep(60000)
Windows.Forms.Cursor.Position = New Point(887, 83)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Thread.Sleep(5000)
Dim x3 As Integer = CInt(TextBox12.Text)
Dim y3 As Integer = CInt(TextBox11.Text)
Windows.Forms.Cursor.Position = New Point(x3, y3)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Timer4.Start()
Else
KillHungProcess("HD-Player.exe")
KillHungProcess("BstkSVC.exe")
Thread.Sleep(10000)
Shell("cmd.exe /k " + """C:\Program Files\BlueStacks_nxt\HD-Player.exe"" --instance Nougat32 --cmd launchApp --package com.addictive.strategy.army")
Thread.Sleep(60000)
Windows.Forms.Cursor.Position = New Point(887, 83)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
Thread.Sleep(5000)
Dim x3 As Integer = CInt(TextBox12.Text)
Dim y3 As Integer = CInt(TextBox11.Text)
Windows.Forms.Cursor.Position = New Point(x3, y3)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
mouse_event(&H4, 0, 0, 0, 0)
End If
End Sub
End Class
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
1 Attachment(s)
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
Re: AutoClicker - Mouse Cursor Position [VB.net 2008]
This was made for a certain bluestacks app on my setup. So some conversion is necessary depending on what your doing.