Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting a mouse click 1

Status
Not open for further replies.

Pete222

Programmer
Dec 29, 2002
85
0
0
GB
I want to able to detect when any mouse button is pressed anywere, may not include form.

Pete.
My site: clix.to/F
 
See my response concerning capturing key presses in thread222-775642.

In my first solution referenced there, you'd need to change WH_KEYBOARD for WH_MOUSE and replace vbKeyBoardProc with an implementation of the MouseProc callback

In the second solution, you need to replace WH_KEYBOARD_LL with WH_MOUSE_LL, and replace LowLevelKeyboardProc with an implementation of the LowLevelMouseProcedure callback

In the final solution (journalling), you don't need to do much. The mouse events are being captured already, you really just need to check HookStruct.message for mouse messages...
 
If you mean that you want to detect a mouse click when any application, not just your VB app, has focus you need a system wide hook. This has to be implemented in a C DLL; can't be written in VB. Once you have the DLL you can call it from your VB app. I did a quick Google search and found this one:


Paul Bent
Northwind IT Systems
 
>This has to be implemented in a C DLL

No, it doesn't. This was the old, standard response to this question, and is incorrect. I figured a way around it for tek-tips about 3 years ago - August 2001 to be precise. Thread222-118564 explains how to do this for key presses, but my advice in my previous post in this thread suggests how to change it to work for mouse events.

Finally, about 6 months after the initial solution, figured out the journalling solution (most recently detailed in thread222-775642, to which I refered in my initial post) to get around the limitations inherent in the LowLevel<x> technique (wouldn't work for anything pre NT4 SP3). The journalling solution has one major disadvantage - it slows down your system since it filters every message...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top