Modify existing C# keyboard listener code to intercept message

Existing stack overflow question works great, except I need to prevent the key press from going through. To quote the original author of the post:

If you for some reason want to intercept system keys (creating e.g. Alt+Tab replacement) and preventing windows of handling them you must change the BeginInvoke to Invoke. Also adding Handled property to KeyDown, KeyUp events to see if it is being handled. After that you either call the CallNextHookEx or not.)

I apologize for my ignorance but I do not know how to handle this. Can anyone point me in the right direction for making these modifications? I am willing and able to learn, just not sure where to start.

-------------Problems Reply------------

If you don't want other apps to see the keys, don't invoke CallNextHookEx.

Per MSDN documentation on this Win32 call,

Calling CallNextHookEx is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.

Category:c# Views:0 Time:2011-11-15
Tags: keyboard wpf

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.138 (s). 11 q(s)