How to hook mouse input?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I am coding for an application with dialog window. I need intercept mouse input.
I need catch raw input, pretty much everything for WM_INPUT: such as Left/Middle/Right button down/up, srcoll/wheel, pull and drag, device source.

I checked SetWindowsHookEx, it seems it can't catch so much infor, only LButton RButton Down/Up? What function should I use or maybe I should ask how to hook Dialog box message Proc?

Thanks
 
june said:
Hi, I am coding for an application with dialog window.
I need intercept mouse input. I need catch raw input,
pretty much everything for WM_INPUT: such as
Left/Middle/Right button down/up, srcoll/wheel,
pull and drag, device source.

Can I ask you why you need to do this?
I checked SetWindowsHookEx, it seems it can't
catch so much infor, only LButton RButton Down/Up?

A hook of type WH_MOUSE_LL catches somewhat more. Does it provide enough
coverage for you?
What function should I use or maybe I should
ask how to hook Dialog box message Proc?

Well, in case you don't know child windows in dialogs without the
WS_EX_NOPARENTNOTIFY style bit will send a WM_PARENTNOTIFY message to notify
the owner of mouse events in the child. Does that help?

Regards,
Will
 
Can I ask you why you need to do this?

It is for hardware testing, I need test the each button of mouse function well or not.
A hook of type WH_MOUSE_LL catches somewhat more. Does it provide enough
coverage for you?

I checked WH_MOUSE_LL, it says callback function for it
CALLBACK LowLevelMouseProc( int nCode, WPARAM wParam,
LPARAM lParam);
nCode
[in] ....... This parameter can be one of the following values.
HC_ACTION
The wParam and lParam parameters contain information about a mouse message.

wParam
[in] This parameter can be one of the following messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN, or WM_RBUTTONUP.
---- seems not cover all I need
Well, in case you don't know child windows in dialogs without the
WS_EX_NOPARENTNOTIFY style bit will send a WM_PARENTNOTIFY message to notify
the owner of mouse events in the child. Does that help?

Sorry I must mis-interpret it. It is a dialog window (MFC), not a pop out dialog. No parent window. All WM_Input test is for the dialog window
Regards,
Will

Thank you, Will

Jun
 
june said:
It is for hardware testing, I need test the each button of mouse function
well or not.

You can't just build an application to respond to the messages without
tricks?
The wParam and lParam parameters contain information about a mouse message.

wParam
[in] This parameter can be one of the following messages: WM_LBUTTONDOWN,
WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN, or WM_RBUTTONUP.
---- seems not cover all I need

It looks to me like the MSLLHOOKSTRUCT structure whose address is passed in
lParam has information about the "X Buttons" too. The X Buttons are
described here:

http://msdn.microsoft.com/library/d...face/userinput/mouseinput/aboutmouseinput.asp
Sorry I must mis-interpret it. It is a dialog window (MFC), not a pop out
dialog. No parent window. All WM_Input test is for the dialog window

Messages are routed to windows. When those windows are controls defined by
the system, then it is not easy either to see how a message is handled or to
modify the handling. To do that you can get the control to pass a copy of
the message to its parent (typically a user dialog). It's not the same thing
as a hook but it does allow you to inspect or modify behavior. I had thought
that you simply wanted to intercept messages destined for another window.

In general, hooks (especially system hooks) should be avoided. They are very
intrusive. And it is far to easy for a hook procedure to cause a change in
behavior just because it is there. Check the docs for the low level hook.
They specifically warn not to spend too much time (more than the period
specified here: HKEY_CURRENT_USER\Control
Panel\Desktop\LowLevelHooksTimeout) in the handler.

Regards,
Will
 
Back
Top