Advertisement Jump to content
Sign in to follow this  
Norman Barrows

disable windows key - hook or message pump?

This topic is 1763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

As far as I know it has to be done as a keyboard hook.  ALT and F10 can be handled with the usual message pump though.

Edited by Nypyren

Share this post


Link to post
Share on other sites

Why not just pause your application when the user switches?

 

Even the Elder Scrolls Online beta (which can't be paused, obviously) was quite happy switching between apps, which can be really useful from a users/developers perspective.

Edited by mark ds

Share this post


Link to post
Share on other sites

There different meanings of disabling the windows key.

 

If you are building a kiosk-style program you can disable it through various methods, and also modify the system so the key event gets handled by your application. That probably isn't what you are talking about, but just leaving it out there since it meets your wording.

 

 

For games, be very cautious about disabling any system-level functionality. It can go far beyond just confusing your users, it can make them very angry.

 

There are some games where players use alt as a hotkey, use tab as a hotkey, and are occasionally bumping alt+tab together and accidentally swapping applications. There are some games where players are rapidly pounding on the keys around the start button and accidentally bump the key.  If you want to prevent access on those keystrokes make it a highly visible option so players know how to disable your feature.  StarCraft 2 is a great example of this.

 

You can accomplish the technical side by consuming the WM_SYSKEYDOWN and WM_SYSKEYUP events that correspond to the specific event you want to prevent. In addition to alt+tab, you may want to capture VK_LWIN, VK_RWIN, and VK_APPS.

Share this post


Link to post
Share on other sites

I have never found an alternative to keyboard hook - although i have never wanted to disable it per-se, just disable its usual function and make it available as a regular key for keybinds.

 

However, as frob mentioned - have an easy to access option for disabling the override.

 

OT: Similarily, might want to consider optionally disabling sticky keys etc whenever your game has focus (you can do that with SystemParametersInfo). Specifically: STICKYKEYS, TOGGLEKEYS and FILTERKEYS.

Share this post


Link to post
Share on other sites


Why not just pause your application when the user switches?

 


There are some games where players are rapidly pounding on the keys around the start button and accidentally bump the key.

 

that's why.  <g>.

 

Caveman does support full task switching now. Even gets the windows mouse cursor correct, which Skyrim doesn't. 

 

but its also a game where one can accidentally hit the windows button (start menu button) in the heat of combat. 

 


You can accomplish the technical side by consuming the WM_SYSKEYDOWN and WM_SYSKEYUP events that correspond to the specific event you want to prevent. In addition to alt+tab, you may want to capture VK_LWIN, VK_RWIN, and VK_APPS.

 

I suspected as much.    why mess with the low level hook, when you already have to process the incoming messages anyway, and can just intercept them there.

 

I do not plan to disable alt-tab. only the windows key. the apps key would probably be a good idea too. 

 


OT: Similarily, might want to consider optionally disabling sticky keys etc whenever your game has focus (you can do that with SystemParametersInfo). Specifically: STICKYKEYS, TOGGLEKEYS and FILTERKEYS.

 

yes, i found that too during my online search. in that case, i find its VERY rare that one accidentally triggers sticky keys. if one does, a menu pops up, you simply turn them off, then alt-tab back to the game. i don't think this rare special case needs anything more than that. also, users who actually use such features should be used to having to turn them off to play games. 

 

i'd prefer to disable as little as possible - leaving it to the user to explicitly disable incompatible software (like sticky keys) BEFORE launching the game.

 

but things like the windows key could really use a disable option - its just too easy to press it accidentally in combat - depending on keyboard layout of course.

 

here's MS's official web page on the subject....

 

Disabling Shortcut Keys in Games:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee416808(v=vs.85).aspx

 

but this only describes the hook method, and the stickykeys etc method. the message intercept method is described in various threads about the subject here on gamedev.

Share this post


Link to post
Share on other sites

I would be weary of capturing any default system functionality in an attempt to disable or prevent it's actions.  I've played games that have done just this and find the behavior intrusive and having no merit.  Users should be capable of using their systems as they see fit and it should be their responsibility to make intelligent decisions about bindings, button usage, etc that maximizes their own play style that they find effective; not the game itself.

 

The best middle ground IMO would be that if you wish to offer such a feature, be sure to make it something that the user can toggle ON/OFF depending on their preferences in some game menu screen.  This way, those who fall into the category of hitting the button mid-combat have a reprieve to their mistake while those who want to keep the default button functionality available can do so.

Edited by crancran

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!