Click here to Skip to main content
Click here to Skip to main content

Journaling Input Events

By , 3 Mar 2001
 
  • 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

    About the Author

    Plamen Petrov
    Web Developer
    Germany Germany
    Member
    see www.geocities.com/plamen_petrov2000

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    QuestionHow to catch Ctrl-CmemberWill25 Jun '03 - 4:48 
    Hi,
     
    While this demo. show they way to let the user stopping the record hook by Ctrl+Break, I would like to do this with Ctrl+C also. I have played with the HIBYTE and LOBYTE but getting nowhere. Could someone suggest a way please. Thank you in advance.
     
    Will
    QuestionKeyboard only - doesn't work?memberWill24 Jun '03 - 22:32 
    One of the greates demo of setting journal hooks I can find. Thank you very much. One question, it seems the check box "Only Keyboard Event" doesn't work. Looking at the code I can find no clue. MSDN not helping either of how to check for a mouse message in the EVENTMSG structure. Any insight would be grateful.
     
    Will
    AnswerRe: Keyboard only - doesn't work?memberWill24 Jun '03 - 22:48 
    Believe I found the answer on a Delphi site. The EVENTMSG's message = WM_MOUSEMOVE tells it is a mouse message.

     
    Will
    QuestionHow to control your event play times.?sussAnonymous12 May '03 - 22:26 
    as title
     
    regards
    AnswerRe: How to control your event play times.?memberPlamen Petrov12 May '03 - 22:48 
    The return value of the JournalPlaybackProc() (in my source the name of this finction is JournalPlaybackFunc()) is the time Windows waits before to call the hook again with the next event.
    This time is calculated by the divverence between EVENTMSG.time of two sequencial events.
    GeneralRe: How to control your event play times.?memberWayne Gibson16 Sep '03 - 4:44 
    Did you ever solve this problem.. Because I have the same problem.. I tried it with the orginial source and this seems to have a problem as well..
     
    Any Ideas..
     
    Thanks
    GeneralIt can't work well with win98!!!membernavy5 Jan '03 - 3:51 
    When I start recording, and press down the right key of the mouse, a popup menu will appears, and I can select a item...
    but when I playback the the events recorded currently, the popup menu appear and disappear quickly, and don't select any item...
    Maybe the return value(wait time) of the playback events is shorter than the original interval time between two neighboring events. And the mouse move events are ignored.
     
    But I can't correct the bug.
     
    Who can do it?
     
    navy
     
    zhouhj@mails.tsinghua.edu.cn
    GeneralRe: It can't work well with win98!!!membernavy5 Jan '03 - 16:40 
    It isn't the problem of the return value(wait time).
     
    Maybe we can't ignore the nCode of HC_NOREMOVE.
     
    I am debugging...
     
    navy
    zhouhj@mails.tsinghua.edu.cn
    GeneralLast character has been gonesussAnonymous7 Sep '02 - 7:06 
    Hello,
     
    a little problem ... when you record f.e. 11+NEWLINE and start the makro twice with ALT+P the NEWLINE comes not up ...
     
    Can somebody help ????
     
    Regards
    ManfredUnsure | :~
    GeneralThis source code are OKmemberRousset de Pina17 Feb '02 - 10:00 
    I use your code and it work well on Windows NT and Windows XP. I modify it to get window title of window under cursor or the window who have the focus if it a keyboard message, like this it possible to playback very quickly without wait between each event. I just wait on button down or key down for the good window title
    Best regards

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

    Permalink | Advertise | Privacy | Mobile
    Web01 | 2.6.130523.1 | Last Updated 4 Mar 2001
    Article Copyright 2001 by Plamen Petrov
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid