How to Stop a Journal Playback

Last reviewed: November 2, 1995
Article ID: Q98486
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

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 reference words: 3.00 3.10 3.50 3.51 4.00 95
KBCategory: kbui
KBSubcategory: UsrHks


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.