Huzaifa

Huzaifa

  • NA
  • 7
  • 12.5k

My Auto Clicker and Mouse Mover

Feb 13 2011 2:26 PM
OK, I'm making a mouse mover and clicker, it records mouse moves and has time intervals where you want them to be, but I can't seem to get it to work. It's kind of hard to explain but if you look at the code you might understand what I mean. Check attached file.I know its somewhere near the timer1 sub..
Here's the code: 



Public Class Form1
   Dim CanSelectay As Integer
   Dim m As Integer
   Dim nextClick(n) As Integer
   Dim WaitTime(i) As Single
   Dim TimeForBlinkEffect As Single
   Dim n As Integer
   Dim i As Integer
   Dim i2 As Integer
   Dim i3 As Integer
   Dim StoreX(n) As Integer
   Dim StoreY(n) As Integer
   Dim PosX(n) As Integer
   Dim PosY(n) As Integer
   Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Integer, ByVal Y 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 Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)


   Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
       e.Cancel = True
       Form2.Show()
   End Sub


   Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
       txtLBC.Text = ListBox1.Items.Count
       If e.KeyChar = Chr(Keys.Enter) Then
           txtDummy.Select()
           txtSetX.Text = ""
           txtSetY.Text = ""
           txtSetX.Text = txtCurrentX.Text
           txtSetY.Text = txtCurrentY.Text
           n += 1
           For P = 0 To (Val(txtLBC.Text))
               PosX(P) = txtSetX.Text
               ListBox2.Items.Add(PosX(P))
               PosY(P) = txtSetY.Text
               ListBox3.Items.Add(PosY(P))
               ListBox1.Items.Add("X position " & n & " : " & PosX(P) & "      " & "Y position " & n & " : " & PosY(P))
               P = n + i + i2 + i3
           Next
           LBSI.Enabled = True
       End If
   End Sub


   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.Width = 645
       GroupBox4.Visible = False
       txtDummy.Select()
       TimeForBlinkEffect = 3.5
   End Sub


   Private Sub TPosXTPosY_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TPosXTPosY.Tick
       Dim MousePositionX As Integer = Cursor.Position.X
       Dim MousePositionY As Integer = Cursor.Position.Y
       txtCurrentX.Text = (MousePositionX)
       txtCurrentY.Text = (MousePositionY)
   End Sub


   Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
       Form2.Show()
   End Sub


   Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
       Form2.Show()
   End Sub


   Private Sub btnWTMC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWTMC.Click
       Me.TopMost = False
       If btnWTMC.Text = "Add Wait Time" Then
           i += 1
           For c = 0 To i
               WaitTime(c) = InputBox("Enter time interval between next mouse move. (In Seconds)", "Mouse Position")
               ListBox4.Items.Add(WaitTime(c))
               ListBox1.Items.Add("Time Interval (" & i & ") for " & WaitTime(c) & " seconds.")
               txtDummy.Select()
               LBSI.Enabled = True
               Exit For
           Next
       ElseIf btnWTMC.Text = "Add Left Mouse Click" Then
           i2 += 1
           For b = 0 To i2
               ListBox1.Items.Add("Left Mouse Click (" & i2 & ")")
               txtDummy.Select()
               LBSI.Enabled = True
               Exit For
           Next
       ElseIf btnWTMC.Text = "Add Right Mouse Click" Then
           i3 += 1
           For a = 0 To i3
               ListBox1.Items.Add("Right Mouse Click (" & i3 & ")")
               txtDummy.Select()
               LBSI.Enabled = True
               Exit For
           Next
       End If
   End Sub


   Private Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click
       txtDummy.Select()
       OptionWidth.Enabled = True
   End Sub


   Private Sub OptionWidth_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionWidth.Tick
       If Me.Width = 645 Then
           Do
               Me.Width += 5
           Loop Until Me.Width >= 1099
           OptionsToolStripMenuItem.Text = "Hide &Options"
           btnOptions.Text = "Hide &Options"
           GroupBox4.Visible = True
           Me.Width = 1099
           OptionWidth.Enabled = False
       ElseIf Me.Width = 1099 Then
           Do
               Me.Width -= 5
           Loop Until Me.Width <= 645
           OptionsToolStripMenuItem.Text = "Show &Options"
           btnOptions.Text = "Show &Options"
           GroupBox4.Visible = False
           Me.Width = 645
           OptionWidth.Enabled = False
       End If
   End Sub


   Private Sub chkBoxAOT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkBoxAOT.CheckedChanged
       If chkBoxAOT.Checked = True Then
           Me.TopMost = True
       ElseIf chkBoxAOT.Checked = False Then
           Me.TopMost = False
       End If
   End Sub


   Private Sub ACRepeatUr_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ACRepeatUr.CheckedChanged
       If ACRepeatUr.Checked = True Then
           txtACUr.Select()
       End If
   End Sub


   Private Sub radOpacityOwn_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacityOwn.Checked = True Then
           txtUrOwnOpacity.Select()
       End If
       If radOpacityOwn.Checked = True And Not txtUrOwnOpacity.Text = "" Then
           OpacityChange.Enabled = True
       End If
   End Sub


   Private Sub radOpacity20_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity20.Checked = True Then
           Me.Opacity = 0.2
           OpacityChange.Enabled = False
       End If
   End Sub


   Private Sub radOpacity40_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity40.Checked = True Then
           Me.Opacity = 0.4
           OpacityChange.Enabled = False
       End If
   End Sub
   Private Sub radOpacity60_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity60.Checked = True Then
           Me.Opacity = 0.6
           OpacityChange.Enabled = False
       End If
   End Sub
   Private Sub radOpacity80_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity80.Checked = True Then
           Me.Opacity = 0.8
           OpacityChange.Enabled = False
       End If
   End Sub
   Private Sub radOpacity100_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity100.Checked = True Then
           Me.Opacity = 1
           OpacityChange.Enabled = False
       End If
   End Sub


   Private Sub radOpacityOwn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
       txtUrOwnOpacity.Select()
   End Sub


   Private Sub txtUrOwnOpacity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       If radOpacity20.Checked = True Then
           OpacityChange.Enabled = True
       ElseIf radOpacity20.Checked = False Then
           radOpacity20.Checked = True
           OpacityChange.Enabled = True
       End If
   End Sub


   Private Sub OpacityChange_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpacityChange.Tick
       Me.Opacity = Val(txtUrOwnOpacity.Text) / 10
   End Sub


   Private Sub ACRepeatUr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ACRepeatUr.Click
       txtACUr.Select()
   End Sub


   Private Sub ATRepeatUr_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATRepeatUr.CheckedChanged
       If ATRepeatUr.Checked = True Then
           txtATUr.Select()
       End If
   End Sub


   Private Sub ATRepeatUr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ATRepeatUr.Click
       txtATUr.Select()
   End Sub


   Private Sub txtACUr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtACUr.Click
       ACRepeatUr.Checked = True
       txtACUr.Select()
   End Sub
   Private Sub txtATUr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtATUr.Click
       ATRepeatUr.Checked = True
       txtATUr.Select()
   End Sub


   Private Sub btnMPMan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMPMan.Click
       txtLBC.Text = ListBox1.Items.Count
       txtDummy.Select()
       If txtSetX.Text = "" And txtSetY.Text = "" Then
           MsgBox("Please Input X and Y mouse position values to manually enter position.", MsgBoxStyle.Critical, "Mouse Position")
       ElseIf txtSetX.Text = "" Then
           MsgBox("Please Input X mouse position value to manually enter position.", MsgBoxStyle.Critical, "Mouse Position")
       ElseIf txtSetY.Text = "" Then
           MsgBox("Please Input Y mouse position value to manually enter position.", MsgBoxStyle.Critical, "Mouse Position")
       ElseIf Not txtSetX.Text = "" Or Not txtSetY.Text Then
           n = n + 1
           Me.KeyPreview = False
           For P = 0 To (Val(txtLBC.Text))
               PosX(P + 1) = txtSetX.Text
               PosY(P + 1) = txtSetY.Text
               ListBox1.Items.Add("X position " & n & " : " & PosX(P) & "      " & "Y position " & n & " : " & PosY(P))
               StoreX(P) = PosX(P)
               StoreY(P) = PosY(P)
               P = n + i + i2 + i3
           Next
           LBSI.Enabled = True
           Me.KeyPreview = True
       End If
   End Sub


   Private Sub btnMPClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMPClear.Click
       txtDummy.Select()
       If ListBox1.Items.Count > 0 Then
           Form3.Show()
       ElseIf ListBox1.Items.Count < 1 Then
           MsgBox("There are no mouse positions or wait times recorded to be cleared.", MsgBoxStyle.Critical, "Mouse Positions")
       End If
   End Sub
   Private Sub txtACSpeed_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtACSpeed.TextChanged
       If txtACSpeed.Text = "" Or txtACSpeed.Text = "Set Speed (In Seconds)" Then
       ElseIf Not txtACSpeed.Text = "" Or txtACSpeed.Text = "Set Speed (In Seconds)" Then
           Timer1.Interval = txtACSpeed.Text * 1000
       End If


   End Sub
   Private Sub btnACStrt_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnACStrt.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(btnACStrt, "Starts Auto Clicker")
   End Sub
   Private Sub btnACStop_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnACStop.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(btnACStop, "Stops Auto Clicker")
   End Sub
   Private Sub ACKeepRepeat_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles ACKeepRepeat.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.AutoPopDelay = 3500
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(ACKeepRepeat, "When selected, repeats Auto Clicker's process untill stop button is pressed")
   End Sub


   Private Sub ACRepeatUr_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles ACRepeatUr.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.AutoPopDelay = 5000
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(ACRepeatUr, "When selected, enter amount of times you wish for Auto Clicker's process to be repeated")
   End Sub
   Private Sub ACRepeatOnce_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles ACRepeatOnce.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(ACRepeatOnce, "When selected, repeats Auto Clicker's process only once")
   End Sub


   Private Sub txtACUr_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtACUr.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtACUr, "Enter amount of times to repeat Auto Clicker's process")
   End Sub
   Private Sub txtACSpeed_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtACSpeed.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtACSpeed, "Enter the speed of Auto Clicker in seconds")
   End Sub


   Private Sub txtSetX_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSetX.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtSetX, "Set X mouse position")
   End Sub


   Private Sub txtSetY_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSetY.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtSetY, "Set Y mouse position")
   End Sub


   Private Sub txtCurrentX_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCurrentX.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtCurrentX, "Current X mouse position")
   End Sub


   Private Sub txtCurrentY_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCurrentY.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(txtCurrentY, "Current Y mouse position")
   End Sub


   Private Sub btnMPMan_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMPMan.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(btnMPMan, "Manually add a mouse position")
   End Sub


   Private Sub btnMPClear_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMPClear.MouseHover
       Dim toolTip1 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       toolTip1.ShowAlways = True
       toolTip1.SetToolTip(btnMPClear, "Clear all recorded mouse positions, wait times and clicks")
   End Sub


   Private Sub btnWTMC_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWTMC.MouseHover
       Dim toolTip1 As New ToolTip()
       Dim tooltip2 As New ToolTip()
       Dim tooltip3 As New ToolTip()
       toolTip1.AutomaticDelay = 300
       tooltip2.AutomaticDelay = 300
       tooltip3.AutomaticDelay = 300
       If btnWTMC.Text = "Add Wait Time" Then
           toolTip1.AutoPopDelay = 3000
           tooltip2.ShowAlways = False
           tooltip3.RemoveAll()
           toolTip1.SetToolTip(btnWTMC, "Add wait time between next mouse click and mouse move")
       ElseIf btnWTMC.Text = "Add Left Mouse Click" Then
           tooltip2.AutoPopDelay = 3000
           toolTip1.RemoveAll()
           tooltip3.RemoveAll()
           tooltip2.SetToolTip(btnWTMC, "Add a left mouse click")
       ElseIf btnWTMC.Text = "Add Right Mouse Click" Then
           tooltip3.AutoPopDelay = 3000
           toolTip1.RemoveAll()
           tooltip2.RemoveAll()
           tooltip3.SetToolTip(btnWTMC, "Add a right mouse click")
       End If
   End Sub


   Private Sub radAWT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radAWT.CheckedChanged
       btnWTMC.Text = "Add Wait Time"
   End Sub


   Private Sub radALMC_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radALMC.CheckedChanged
       btnWTMC.Text = "Add Left Mouse Click"
   End Sub


   Private Sub radARMC_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radARMC.CheckedChanged
       btnWTMC.Text = "Add Right Mouse Click"
   End Sub


   Private Sub LBSI_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LBSI.Tick


   End Sub


   Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
       OptionWidth.Enabled = True
   End Sub


   Private Sub btnNewHotkeys_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewHotkeys.Click
       txtDummy.Select()
       Form4.Show()
   End Sub


   Private Sub btnOSKB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOSKB.Click
       txtDummy.Select()
       Form6.Show()
   End Sub


   Private Sub DoubleLoginToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoubleLoginToolStripMenuItem1.Click
       Form7.Show()
   End Sub


   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       txtLBC.Text = ListBox1.Items.Count()
       txtCanSelect.Text = ListBox1.Items.Count() - 1
       CanSelectay = ListBox4.Items.Count
       If txtLBC.Text = 0 Then
           Timer1.Enabled = False
       Else
           For c = 0 To (ListBox1.Items.Count) - 1
               ListBox1.SelectedIndex = c
               If ListBox2.Items.Count > 0 Then
                   ListBox2.SelectedIndex = c
                   ListBox3.SelectedIndex = c
               End If
               If ListBox1.SelectedItem.ToString.Contains("X position") Then
                   SetCursorPos(ListBox2.SelectedItem, ListBox3.SelectedItem)
                   ListBox1.SelectedIndex = c + 1
                   If ListBox2.Items.Count > 0 And ListBox2.Items.Count < ListBox2.Items.Count Then
                       ListBox2.SelectedIndex = c + 1
                       ListBox3.SelectedIndex = c + 1
                   End If
                   If ListBox2.SelectedIndex >= txtCanSelect.Text Then
                       Exit For
                       Timer1.Enabled = False
                   End If
                   If ListBox1.SelectedIndex >= txtCanSelect.Text Then
                       Exit For
                       Timer1.Enabled = False
                   End If
                   Exit For
               End If
               If ListBox1.SelectedItem.ToString.Contains("Time Interval") Then
                   ListBox4.SelectedIndex = c
                   Timer3.Interval = ListBox4.SelectedItem * 1000
                   Timer3.Enabled = True
                   If Timer3.Enabled = False Then
                       ListBox1.SelectedIndex = c + 1
                   End If
                   If ListBox4.SelectedIndex = CanSelectay Then
                       Exit For
                       Timer1.Enabled = False
                   End If
               End If
               If ListBox1.SelectedItem.ToString.Contains("Left Mouse Click") Then
                   mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
                   mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
                   ListBox1.SelectedIndex = c + 1
               End If
               If ListBox1.SelectedItem.ToString.Contains("Right Mouse Click") Then
                   mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
                   mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
                   ListBox1.SelectedIndex = c + 1
               End If
           Next
       End If
   End Sub


   Private Sub btnACStrt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnACStrt.Click
       Timer1.Enabled = True
   End Sub


   Private Sub btnACStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnACStop.Click
       Timer1.Enabled = False
   End Sub


   Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
       Timer3.Enabled = False
       Exit Sub
   End Sub
End Class

Hope you can help =]

Attachment: Pictures.zip