Thursday, October 28

Virtual User only clicks..(Left and right) with loops nd controls



Public Class Form1
Dim result As Integer
#Region "DIMS"
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Short
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 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 Const mouseclickup = 4
Private Const mouseclickdown = 2
#End Region
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RecorderTimer.Tick
Dim Mouse As Point = Control.MousePosition
If GetAsyncKeyState(MOUSEEVENTF_LEFTDOWN) Then
ListBox2.Items.Add("Left")
ListBox3.Items.Add("Right")
ElseIf GetAsyncKeyState(MOUSEEVENTF_RIGHTDOWN) Then
ListBox2.Items.Add("Right")
ListBox3.Items.Add("Right")
Else
ListBox2.Items.Add(Mouse.X)
ListBox3.Items.Add(Mouse.Y)
End If
ListBox1.Items.Add(GetAsyncKeyState(1))
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayTimer.Tick
If ListBox1.Text = "-32767" Or ListBox1.Text = "-32768" Then
mouse_event(mouseclickdown, 0, 0, 0, 0)
mouse_event(mouseclickup, 0, 0, 0, 0)
End If
If ListBox3.Text = "Left" Then
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
ElseIf ListBox3.Text = "Right" Then
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)

ElseIf Not ListBox3.Text = "Left" And Not ListBox3.Text = "Right" Then
Cursor.Position = New Point(ListBox2.Text, ListBox3.Text)
End If

Try
ListBox1.SelectedIndex = ListBox1.SelectedIndex + +1
ListBox2.SelectedIndex = ListBox2.SelectedIndex + +1
ListBox3.SelectedIndex = ListBox3.SelectedIndex + +1
Catch ex As Exception
PlayTimer.Stop()
Me.Refresh()
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RecorderTimer.Start()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
If (My.Computer.Keyboard.ScrollLock = True) Then
RecorderTimer.Stop()
PlayTimer.Stop()
Else
If TextBox1.Text = 0 Or TextBox1.Text < 0 Then
RecorderTimer.Stop()
PlayTimer.Stop()
ElseIf (My.Computer.Keyboard.NumLock = True) Then
ListBox1.SelectedIndex = 0
ListBox2.SelectedIndex = 0
ListBox3.SelectedIndex = 0
PlayTimer.Start()
TextBox1.Text -= 1
End If
End If
Catch ex As Exception

End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.SelectedIndex = 0
ListBox2.SelectedIndex = 0
ListBox3.SelectedIndex = 0
PlayTimer.Start()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
ListBox4.Items.Clear()
End Sub

End Class

No comments: