I added the constants for the Right and Middle buttons in case you want to simulate one of the other buttons. Also you can set the cursors position without using the SetCursorPos API function by using the. You can use the mouse_event API function to simulate any of the mouse buttons being pressed down and being released. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BlueButtonB1.Click Mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 'simulates left button being released Mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'simulates the left button being pressed down Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.TickĬursor.Position = New Point(newX, newY) 'this will move the cursor to the new point Private Shared Sub mouse_event(ByVal dwFlags As UInteger, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As UInteger) Private Const MOUSEEVENTF_RIGHTUP As Integer = &H10 Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8 Private Const MOUSEEVENTF_MIDDLEUP As Integer = &H40 Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = &H20 Private Const MOUSEEVENTF_LEFTUP As Integer = &H4 Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2 I also changed it to use the Cursor.Position method instead of the SetCursorPos API function. I added the code to click the left mouse button at each point that the cursor moves to.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |