Home [ How it Works ] How to Use it Download Limitations About the Author  



   WinMacro uses journal hooks to both record and playback your actions. If you are not aware of what hooks are, they are a special mechanism provided by Windows itself, to monitor/filter messages being passed to applications. Hooks may be system wide, or application specific. System wide hooks can monitor/filter messages passed to any application.

  There are several types of hooks, like Keyboard hooks, Mouse motion hooks, System message hooks, CBT hooks. A Journal hook is also a kind of hook, which can be used to monitor, but not modify system wide messages, and play them back. What WinMacro does is, it uses the journal hook to monitor messages and writes them to a file. Again, during playback, it uses a journal hook to play back messages read from the file. So what is recorded is simply messages, and not actual video.

  I'll give you a very short tutorial on Journal Hooks. First, to set up a Windows Hook, you use the SetWindowsHookEx function, supplying the address of a callback function as a parameter. When Windows decides to send information to the hook, it calls this function. The prototype of this function varies according to the type of hook, but for journal hooks, it's like this.

LRESULT CALLBACK JournalRecordProc(int code,WPARAM wparam,LPARAM lparam);
LRESULT CALLBACK JournalPlaybackProc(int code,WPARAM wparam,LPARAM lparam);

   The first callback function is set as a hook when you want to record messages, and the second one is used when you want to playback them. What you do is implement these functions and take action, depending on the code parameter. lparam is a pointer to an EVENTMSG structure, that contains fields describing the message, like the HWND of the window to which the message is directed, the keystroke value, the type of message (WM_KEYUP...).

When you are implementing JournalRecordProc you store the EVENTMSG structure being passed to the function. (by typecasting from the lparam parameter). When you are playing back, you implement the JournalPlaybackProc function, and copy the EVENTMSG structure (read from file in our case) to the lparam parameter. The system then plays back the message in the EVENTMSG structure.

  For more details, have a look at the MSDN documentation for SetWindowsHookEx, JournalRecordProc and JournalPlaybackProc. The source code for WinMacro can also be useful.

  In addition to journal hooks, WinMacro also uses a GetMsg Hook to monitor for cancellation of recording/playback when user presses Ctrl+Esc or Ctrl+Alt+Del. Because the WM_CANCELJOURNAL message is not sent to any particular windows, I had to use the GetMsg systemwide hook to look for it and stop the recording/playback accordingly. The sytem evicts the hook though, whether the application acts on the message or not.

Google
Hosted by www.Geocities.ws

1