Advertisement
TheVideoVolcano

Mouse recorder

Mar 29th, 2013
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.74 KB | None | 0 0
  1. 'Mouse recording...
  2.  
  3. Public Class Form1
  4.     'You Need This Line Of Code... To simulate Mouse Clicks, and Such...
  5.     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)
  6.  
  7.     'Use These latter on in your Application.
  8.     'mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  9.     'mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  10.     'mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
  11.     'mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
  12.  
  13.     'The API that handles mouse events, like clicking and such.
  14.     Private Const MOUSEEVENTF_LEFTDOWN = &H2
  15.     Private Const MOUSEEVENTF_LEFTUP = &H4
  16.     Private Const MOUSEEVENTF_RIGHTDOWN = &H8
  17.     Private Const MOUSEEVENTF_RIGHTUP = &H10
  18.  
  19.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Integer
  20.     Private Const VK_LBUTTON = &H1
  21.     Private Const VK_RBUTTON = &H2
  22.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  23.         ax.Items.Clear()
  24.         ay.Items.Clear()
  25.         theclicking.Items.Clear()
  26.         Timer1.Start()
  27.     End Sub
  28.  
  29.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  30.       aX.Items.Add(Cursor.Position.X)
  31.         ay.Items.Add(Cursor.Position.Y)
  32.  
  33.         If (GetAsyncKeyState(1)) Then
  34.             theclicking.Items.Add("LeftClick")
  35.         Else
  36.             theclicking.Items.Add("Nothing")
  37.         End If
  38.  
  39.         If (GetAsyncKeyState(9)) Then
  40.             theclicking.Items.Add("TabPress")
  41.         Else
  42.             'Nothing.
  43.         End If
  44.         ax.SelectedIndex = ax.SelectedIndex + 1
  45.         ay.SelectedIndex = ay.SelectedIndex + 1
  46.         theclicking.SelectedIndex = theclicking.SelectedIndex + 1
  47.     End Sub
  48.  
  49.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  50.         ax.SelectedIndex = 0
  51.         ay.SelectedIndex = 0
  52.         theclicking.SelectedIndex = 0
  53.  
  54.         Timer2.Start()
  55.     End Sub
  56.  
  57.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  58.  
  59.         If ax.SelectedIndex = ax.Items.Count - 1 = True Then
  60.             Timer2.Enabled = False
  61.         Else
  62.             ax.SelectedIndex = ax.SelectedIndex + 1
  63.             ay.SelectedIndex = ay.SelectedIndex + 1
  64.             theclicking.SelectedIndex = theclicking.SelectedIndex + 1
  65.  
  66.             Cursor.Position = New Point(ax.SelectedItem, ay.SelectedItem)
  67.  
  68.             If theclicking.SelectedItem = "LeftClick" Then
  69.                 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  70.             ElseIf theclicking.SelectedItem = "Nothing" = True Then
  71.                 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  72.             End If
  73.  
  74.             If theclicking.SelectedItem = "TabPress" Then
  75.                 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  76.                 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  77.             End If
  78.         End If
  79.     End Sub
  80.  
  81.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  82.         Timer1.Stop()
  83.     End Sub
  84.  
  85.     Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  86.         If e.KeyCode = Keys.F1 Then
  87.             Timer2.Stop()
  88.         End If
  89.     End Sub
  90.  
  91.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  92.  
  93.     End Sub
  94.  
  95.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  96.         ax.Items.Clear()
  97.         ay.Items.Clear()
  98.         theclicking.Items.Clear()
  99.     End Sub
  100. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement