Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 98486 - Last Review: July 11, 2005 - Revision: 1.3
How To Stop a Journal Playback
This article was previously published under Q98486
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.
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 );
.
.
.
APPLIES TO
- Microsoft Platform Software Development Kit-January 2000 Edition
- Microsoft Windows Software Development Kit 3.1
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please