Oh well in that case:
vb Code:
Public Class Form1
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
End Class
It will messagebox "L mouse button pressed" everytime you click the button and no matter where you click (even outside the form).
Justin
Oh and "Global" to one person may mean a totally different thing to another, without futher elaboration of course.