We help IT Professionals succeed at work.

A brief understanding on how capturing windows messages work

afos21
afos21 asked
on
Medium Priority
253 Views
Last Modified: 2013-11-20
My aim is to handle selected windows messages. I've been navigating through Internet and they are all very mixed up. I would be grateful if someone will link me a tutorial or help me understand how the procedure works since i'm completely lost.
Comment
Watch Question

Commented:
You want to capture windows messages in your MFC application? You can handle messages to the current window you're conerned with. Look at the documentation for CWnd:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.asp

Most of the OnXXX() member functions are mapped message handlers. For instance:

    CWnd::OnLButtonDown();

will fire when the user left clicks in that window. Are you developing for MFC, or just plain win32? And what messages do you want to handle? If you give this information I can give specific examples for you.

CERTIFIED EXPERT
Author of the Year 2009

Commented:
... Or are you interested in capturing/monitoring window messages in *other applications* (other than the programs you write yourself).  The techniques are very different.

Author

Commented:
actually, my purpose is to write a mouse recorder application. I wasn't given any restrictions. I'm free to choose any programming language i want. They told me is much easier to do it with java but i choosed c++ because i'm more familiar with
CERTIFIED EXPERT
Author of the Year 2009
Commented:
You need to write what is called a Windows Hook.  In order to record mouse clicks and movement in an external APP, it must be a global hook  and it must reside in a DLL.

Here is a link to some source code that does waht you want
      http://www.codeproject.com/tools/hookmanager.asp

Here is one answer from another question at EE:
      http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20297950.html
And here is an EE search to a bunch of related questions:
     http://search.experts-exchange.com/jsp/search.jsp?query=hook%20wh_mouse%20global%20DLL&topics=80#topSearch

Here is the MSDN topic at Microsoft:
    http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/abouthooks.asp

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.