473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to hook mouse input?

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

Nov 17 '05 #1
3 8383
"june" <ju**@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com...
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
Nov 17 '05 #2

"William DePalo [MVP VC++]" wrote:
"june" <ju**@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com...
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?
It is for hardware testing, I need test the each button of mouse function well or not.
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?


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
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?


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

Nov 17 '05 #3
"june" <ju**@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
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/de...mouseinput.asp
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

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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mohammad | last post by:
Can someone explain to me what a hook is? Does it has something to do with a debugger? Thanks
1
by: ayiiq180 | last post by:
my hook already in a dll and the handle is shared,but the hook cant work well,when i run the application,My mouse click the application's view,the hook work well,but when i click the other...
5
by: Logan Mckinley | last post by:
I need to know where the cursor is (x,y) and when it moves even when it is not over my form. I know i can get the current location with: System.Windows.Forms.Cursor.Position.X...
3
by: Per Larsson | last post by:
Hi! I've developed an application, and I want to use a semi opac form to show the help. The idea is to show the transparent help form on top (TopMost = True)and still be able to work with the...
5
by: Noozer | last post by:
I'm trying to write a small application that intercepts middle clicks anywhere in the Windows environment. I want to perform different actions, based on the application that the mouse pointer was...
7
by: jpierson | last post by:
Hi, I am tryin to create a keyboard hook that sends the keystroke ctrl + pause/break. I haven't used keyboard hooks before so I'm not too sure how to use them public int MyKeyboardProc(int...
3
by: The Saeed | last post by:
Hello, I try to use hook mouse event for a specific application (thread) in C#, I can use global hook, but i want to now which application sends mouse event, did you now what should I do? I set a...
0
by: Johnny J. | last post by:
I want to intercept mouse events in my application and in certain cases cancel them. I used the code from CodeProject to implement a mouse hook: ...
22
by: schneider | last post by:
I need to hook the system mouse down event. I'm trying to replicate how a context menu hides when the mouse clicks outside of the control. Thanks, Schneider
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.