Code:
Imports System.Threading
Public Class Form1
Dim counter As Integer
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If counter = 0 Or counter = Nothing Then
counter = 1
Label2.Text = "ON"
Label2.BackColor = Color.Lime
Thread.Sleep(Integer.Parse(TextBox1.Text))
macro()
Else
counter = 0
Label2.Text = "OFF"
Label2.BackColor = Color.Red
End If
End Sub
Private Sub macro()
Windows.Forms.Cursor.Position = New System.Drawing.Point(170, 340)
SendMessage(&H2, 0, 0, 0)
Thread.Sleep(200)
SendMessage(&H4, 0, 0, 0)
End Sub
End Class
Right now i can trigget my mouse to move by itself to the location i want, but i cannot trigger it to click and vs.net pop out an exception : PInvokeStackImbalance
How to fix this guys?