开发者

Is it possible to trap the Windows Start Menu popup via Windows key(possibly without a hook)?

开发者 https://www.devze.com 2023-03-29 13:46 出处:网络
I\'ve been working on an input event system. I mapped all the keys on my own keyboard, the scancodes and so on, including both windows keys.

I've been working on an input event system. I mapped all the keys on my own keyboard, the scancodes and so on, including both windows keys. When I press them, the program successfully receives the distinct keydown events for them without any trouble. When I release the keys, however, the Start Menu pops up, obscuring the program in windows mode, or even minimizing it in fullscreen.

So my problem lies in suppressing that.

Arma 2, a Military Simulator/Game allows commands to be mapped on those keys without any trouble.

Where do I have to catch that event? Can I do it for my own window as long as it has focus? Am I going to be stuck with a disabled win-key as long as it is running? Or something else?

Googling it was mainly fruitless due to Windows key also referring to the product key, and when I did find something, it usually flat out disabled the whole button. I just want to suppress the popup.

Edit: I tried

case WM_SYSCOMMAND:
        switch(wParam)
        {

        case SC_TASKLIST:
            return 0;

        default:
            break;
        }

But that gave me very odd results. If I spammed the winkeys and only the winkeys, it seemed to work, as soon as I moved the mouse while doing so, it didn't, the start menu would pop up again.

Edit: I also tried hooks, but on win7 they get removed if the callback takes too much time, which can happen when large data is loaded, so they suggest a dedicated thread for it, but I think that's overkill for just one key that needs handled.

I just want to know where the Start Menu gets called. My own program? The system? This is so friggin annoying, I am contemplating trying to reach the people from Bohemia Interactive and ask them how they did it.

Just this one key, sheesh Microsoft...even with "Super key/superkey" searc开发者_JAVA技巧h terms, I usually only get flat out disabling methods, from registry changes to third party background programs.

Bah!


This artcile was relating to C# but may point you in the right direction;

From MSDN:

A global hook monitors messages for all threads in the same desktop as the calling thread. A thread-specific hook monitors messages for only an individual thread. A global hook procedure can be called in the context of any application in the same desktop as the calling thread, so the procedure must be in a separate DLL module. A thread-specific hook procedure is called only in the context of the associated thread.

This was the most helpful link in order to answer the question in the above article


The Raw Input API should solve your problem.

http://msdn.microsoft.com/en-us/library/ms645543.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号