Click here to Skip to main content
15,867,488 members
Articles / Programming Languages / C++
Article

Journaling Input Events

Rate me:
Please Sign up or sign in to vote.
4.84/5 (17 votes)
3 Mar 2001 134.8K   4K   54   29
A tool for recording and playback of keyboard and mouse input
  • Download source files - 18 Kb
  • Download demo project - 74 Kb
  • Sample Image - HookManager.jpg

    Introduction

    This is an example for installing an application-defined hook procedures using Win32 SetWindowsHookEx() function. This project implements only WH_JOURNALRECORD and WH_JOURNALPLAYBACK hooks. I was looking for more information and sample programs, but the only sample I'd found was Hooks32, an old Win32 project. Because I didn't find any information about these problems into the developer sites (which I know), I decided to publish this simple tool.

    The application can be used to automate some routine tasks, for example - testing. Start the target application, launch the HookManager, and press the "Start Recording" button. Then HookManager minimizes itself and starts tracking keyboard and mouse events. When the recording is started, pressing CTRL+BREAK can stop it. Windows stops the recording and playback if the user presses CTRL+ALT+DEL or CTRL+ESC, which generates WM_CANCELJOURNAL system message. But, be careful when you are journaling the mouse events! The recorded mouse events are with the current pointer coordinates, and if you close the target application and open it again, it will appear on different position, so the mouse events will go to wrong place.

    This tool can be extended to do some more things. For example: the recorded events can be edited by changing the keystrokes (with different form data, etc.). But this is very precise work, because every pressed button generates 2 messages - WM_KEYDOWN and WM_KEYUP. The generated character depends from the state of other buttons - CTRL, SHIFT, CAPSLOCK, etc.

    I haven't tested the application on Windows NT yet, but with Win98 it works well. I will be glad to receive ideas about extending the functionality.

    Plamen Petrov, Varna, Bulgaria

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    Software Developer
    Bulgaria Bulgaria
    see www.geocities.com/plamen_petrov2000

    Comments and Discussions

     
    QuestionMouse cursor disappears Pin
    Chris Hills2-Mar-10 11:54
    Chris Hills2-Mar-10 11:54 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.