Jump to content

  • Log In with Google      Sign In   
  • Create Account


disable windows key - hook or message pump?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Norman Barrows   Crossbones+   -  Reputation: 1845

Like
0Likes
Like

Posted 20 March 2014 - 05:02 PM

disable windows key - hook or message pump?

 

can the windows key be trapped via the message queue, or must one use the keyboard hook?

 


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 


Sponsor:

#2 Nypyren   Crossbones+   -  Reputation: 3674

Like
0Likes
Like

Posted 20 March 2014 - 05:09 PM

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, 20 March 2014 - 05:10 PM.


#3 mark ds   Members   -  Reputation: 1070

Like
0Likes
Like

Posted 20 March 2014 - 05:39 PM

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, 20 March 2014 - 05:39 PM.


#4 frob   Moderators   -  Reputation: 18836

Like
3Likes
Like

Posted 20 March 2014 - 07:49 PM

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.


Check out my personal indie blog at bryanwagstaff.com.

#5 tanzanite7   Members   -  Reputation: 1139

Like
0Likes
Like

Posted 21 March 2014 - 01:04 AM

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.



#6 Norman Barrows   Crossbones+   -  Reputation: 1845

Like
0Likes
Like

Posted 21 March 2014 - 08:59 AM


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.


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 


#7 crancran   Members   -  Reputation: 354

Like
0Likes
Like

Posted 21 March 2014 - 12:00 PM

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, 21 March 2014 - 12:01 PM.


#8 Norman Barrows   Crossbones+   -  Reputation: 1845

Like
0Likes
Like

Posted 24 March 2014 - 02:40 PM

yep, option to disable windows key sounds like the way to go.


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS