

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) Return CallNextHookEx( g_hKeyboardHook, nCode, wParam, lParam ) Note that this will not block the Xbox Game Bar hotkeys (Win+G, Win+Alt+R, etc.) LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )īEatKeystroke = (g_bFullscreen & g_bWindowActive & ((p->vkCode = VK_LWIN) || (p->vkCode = VK_RWIN))) G_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(nullptr), 0 ) INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) Using a low-level keyboard hook to disable the Windows key HHOOK g_hKeyboardHook = nullptr This method is used by DXUT and is illustrated in the following code example.Įxample 1. This method also works with least-privileged user accounts (also known as Standard User accounts). This method works on Windows 2000 and later versions of Windows. The code in Example 1 does this by handling the WM_ACTIVATEAPP message. This means that you must be careful to ensure that the Windows key is not disabled when the application is deactivated. The low-level keyboard hook shown in Example 1 remains in effect even if a user minimizes the window or switches to another application.

Use a low-level keyboard hook to filter out the Windows key from being processed.

Simply using the SHIFT key as a game button can inadvertently execute the StickyKeys shortcut which may display a warning dialog. If users accidentally press the Windows key (located near these keys), they can cause themselves to suddenly jump out of the application, which ruins the game experience. The SHIFT key and the CTRL key are often used as fire or run buttons in games. This articles describes how to temporarily disable keyboard shortcuts in Microsoft Windows to prevent disruption of game play for full screen games.
