[RESOLVED] Global Mouse Hook
Got another problem :/
Code:
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As UShort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
t = New Threading.Thread(New Threading.ThreadStart(AddressOf threadfunc))
t.Start()
End Sub
Public Sub threadfunc()
While running
Dim pressed As Boolean = KeyStatus(Keys.LButton)
If pressed Then
MessageBox.Show("L mouse button pressed")
End If
End While
End Sub
Public Shared ReadOnly Property KeyStatus(ByVal Key As Keys) As Boolean
Get
If Key = Keys.LButton AndAlso My.Computer.Mouse.ButtonsSwapped Then
Key = Keys.RButton
MessageBox.Show("right button pushed")
ElseIf Key = Keys.RButton AndAlso My.Computer.Mouse.ButtonsSwapped Then
Key = Keys.LButton
MessageBox.Show("Lbutton button pushed")
End If
Return GetAsyncKeyState(Key) And &H8000US
End Get
End Property
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
running = False
t.Join()
End Sub
This was the code
and this is the thread HERE
Ok its working and everything but when i want to perform something when click is noticed it says i cant cross-threads or something can you help me out with that please, thanks.