none
How to intercept WIN key default behavior RRS feed

  • Question

  • I am trying to intercept default behavior of WIN key to disable Start menu appearing. I use global keyboard hook-code based on this example: Processing Global Mouse and Keyboard Hooks in C#, adapted for WPF.

    I intercept WM_KEYUP event for VK_LWIN / VK_RWIN key and disable its default behavior by returning -1 in my hook procedure. It works fine - Start menu not appears. But WIN key status remains 'pressed' and it causes adverse keyboard effects. This problem sometimes appearing with other keys (Shift/Ctrl/Alt).

    Using function SendInput to simulate key-up event helps, but causes Start menu to appear. Using function SetKeyboardState with zero key status has no effect - WIN key status stays 'pressed'.

    Question is: how clear 'pressed' state of particular key?

    PS: my operating system is Windows 7

    Thanks.


    Friday, April 1, 2011 11:12 AM

Answers

  • I am stupid... I should intercept both events: WM_KEYDOWN and WM_KEYUP (not only WM_KEYUP) for particular key. It solved my problem.

    Sorry for sending this foolish question. Moderator may delete it...

    • Marked as answer by tms320 Friday, April 1, 2011 12:05 PM
    Friday, April 1, 2011 12:05 PM