Description

The WH_JOURNALPLAYBACK hook provides a way to play back messages to the Windows operating system. When I say “play back messages,” I mean to post prerecorded messages to the raw input thread (RIT) message queue so that the system can process them. From the system’s point of view, messages played back in this manner are no different from messages input through a keyboard or mouse.

This hook works differently than the other hooks do. Instead of intercepting messages within the message stream, this hook posts messages to the RIT message queue. After you install this hook, the message loop in the RIT ceases to remove messages from its message queue that were placed there by normal keyboard and mouse input, and it starts accepting only messages from the hook’s filter function. More specifically, it receives the actual message from the filter function’s lParam argument. This is why the system seems as though it is not accepting input from the keyboard or mouse while the hook is installed.

While this hook is installed, events that the mouse and keyboard produce are placed in the RIT’s message queue, as they normally would be. These queued messages are not passed on to the RIT’s message loop until the WH_JOURNALPLAYBACK hook is removed. After this hook is removed, the queued messages are sent to their respective windows. The memory space that can be allocated for the message queue is not infinite; therefore, mouse or keyboard events are lost after this queue is filled.

The ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.