Click to See Complete Forum and Search --> : Global detection of mouseclick


AndyK
January 26th, 2000, 10:20 PM
How to detect if mouse had been clicked anywhere on the screen, not only form....

Thank You

Lothar Haensler
January 27th, 2000, 06:53 AM
check out this article on vbaccelerator
http://vbaccelerator.com/codelib/hook/vbalhook.htm
it tells you everything about hooks and how to use the in vb

Lothar Haensler
January 27th, 2000, 06:55 AM
on second thought...
you could also use GetAsyncKeyState API to find out if a certain mouse button has been pressed.

AndyK
January 27th, 2000, 02:02 PM
hmm, this is not exactly what I needed I meant global as if the mouse was pressed anywhere on the screen not on the form or control only, even if I doubleclick "My Computer" and form is minimized it still detects mouse click, about GetAsyncKeyState I'll see if I can figure out how to make it work, because I had never used it before, anyway thank you from replying

Aaron Young
January 27th, 2000, 03:50 PM
Here's how you can use the GetAsyncKeyState API:
private Declare Function GetAsyncKeyState Lib "user32" (byval vKey as Long) as Integer
private Const VK_LBUTTON = &H1
private Const VK_RBUTTON = &H2

private Sub Form_Load()
Timer1.Interval = 100
End Sub

private Sub Timer1_Timer()
If GetAsyncKeyState(VK_LBUTTON) then
Caption = "Left Click"
ElseIf GetAsyncKeyState(VK_RBUTTON) then
Caption = "Right Click"
else
Caption = ""
End If
End Sub



Aaron Young
Analyst Programmer
ajyoung@pressenter.com
aarony@redwingsoftware.com

February 1st, 2000, 10:21 AM
Thanks a lot for helping :o)


[]'s