How to Stop a Journal PlaybackLast reviewed: November 2, 1995Article ID: Q98486 |
The information in this article applies to:
SUMMARYTo 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 INFORMATIONTo 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 reference words: 3.00 3.10 3.50 3.51 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |