A brief understanding on how capturing windows messages work

Posted on 2006-03-23
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.
Question by:afos21
    LVL 7

    Expert Comment

    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:

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


    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.

    LVL 49

    Expert Comment

    ... 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 Comment

    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
    LVL 49

    Accepted Solution

    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

    Here is one answer from another question at EE:

    And here is an EE search to a bunch of related questions:

    Here is the MSDN topic at Microsoft:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now