Handmade Hero » Forums » Code » Win+d shortcut mistery
Isrraka
Israel Fernández Angullo
13 posts
#12970 Win+d shortcut mistery
3 weeks, 3 days ago

Hi!

While debugging my handmade engine the shortcut win+D stop working. Other windows shortcuts like win+e work as usual.
Do the win key should be avoided to prevent conflicts with the OS? or maybe is not the case?
I thought I understood how to handle window's input properly, but obviously that's not the case.
Why win+d don't work? Did I break something?
Can anyone explain or point me to an explanation about how or when windows shortcuts work?

Thanks!
mrmixer
Simon Anciaux
265 posts
#12984 Win+d shortcut mistery
3 weeks, 2 days ago

Have a look at RegisterHotKey and WM_HOTKEY.
Upon finding a match, the system posts the WM_HOTKEY message to the message queue of the window with which the hot key is associated. If the hot key is not associated with a window, then the WM_HOTKEY message is posted to the thread associated with the hot key.
Which I think means that W+D is processed by the "desktop window" and so the key messages are not sent to your window (or your window lost the focus so it doesn't get key messages anymore).

These keys are labeled with the Windows logo. Hotkeys that involve the Windows key are reserved for use by the operating system.
So it's probably not a good idea to use the windows keys for shortcuts.

In a small test on my machine (windows 7) when I try any windows shortcut (w+d, w+e, w+r, w+p...) my application only get the windows key messages, never the letters (using virtual keys or raw input).

Disable windows shortcut (not what you want but could help).
Isrraka
Israel Fernández Angullo
13 posts
#12986 Win+d shortcut mistery
3 weeks, 2 days ago

Thank you very much for the links!
Disable windows shortcuts is really usefull! All the games using wasd and ctrl/alt should do it!

Again, thanks!
mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#12989 Win+d shortcut mistery
3 weeks, 2 days ago Edited by Mārtiņš Možeiko on Aug. 31, 2017, 6:50 a.m.

I am actually very sad if standard windows shortcuts don't work for application or game. I like to use Alt+Tab to get out of game. Or just press Alt+F4 to quickly close it. Or use Ctrl+Shift+Esc to get to task manager if game hanged and I need to kill it. Disabling shortcuts would make some of these things impossible.
mrmixer
Simon Anciaux
265 posts
#12991 Win+d shortcut mistery
3 weeks, 2 days ago

The link above only disable the "windows logo keys" (not the shortcuts, just the keys), so other shortcuts should continue to work. And I agree that keeping alt + tab and ctrl + alt + esc is important. Adding Alt + f4 is a plus.

I encountered a game (I don't remember which one) that had an option that let the user disable the "windows keys". Maybe it's the way to go ?