HOWTO: Stop a Journal Playback
ID: Q98486
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK)
-
Microsoft Windows Software Development Kit (SDK) 3.1
-
Microsoft Windows 2000
SUMMARY
To stop a "journal playback" when a specified key is pressed, the
filter function must determine whether the key was pressed and then
call the UnhookWindowsHookEx function to remove the WH_JOURNALPLAYBACK
hook.
MORE INFORMATION
To determine the state of a specified key, the filter function must
call the GetAsyncKeyState function when the nCode parameter equals
HC_SKIP. The HC_SKIP hook code notifies the WH_JOURNALPLAYBACK filter
function that Windows is done processing the current event.
The GetAsyncKeyState function determines whether a key is up or down
at the time the function is called, and whether the key was pressed
after a previous call to the GetAsyncKeyState function. If the most
significant bit of the return value is set, the key is down; if the
least significant bit is set, the key was pressed after a preceding
GetAsyncKeyState call.
If the filter function calls the GetAsyncKeyState function after the
specified key was pressed and released, then the most significant bit
will not be set to reflect a key-down. Thus, a test to check whether
the specified key is down fails. Therefore, the least significant bit
of the return value must be checked to determine whether the specified
key was pressed after a preceding call to GetAsyncKeyState function.
Using this technique of checking the least significant bit requires a
call to the GetAsyncKeyState function before setting the
WH_JOURNALPLAYBACK hook. For example:
// When setting the journal playback hook.
.
.
.
// Reset the lease significant bit.
GetAsyncKeyState( VK_CANCEL );
// Set a system-wide journal playback hook.
g_hJP = SetWindowsHookEx( WH_JOURNALPLAYBACK,
FilterFunc,
g_hInstDLLModule,
NULL );
.
.
.
// Inside the filter function
.
.
.
if ( nCode == HC_SKIP )
if ( GetAsyncKeyState( VK_CANCEL) )
UnhookWindowsHookEx( g_hJP );
.
.
.
Additional query words:
Keywords : kbHook kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS
Version : WINDOWS:3.1
Platform : WINDOWS
Issue type : kbhowto