![]() Because it is possible for the application to fail to exit correctly, you should write these settings to persistent storage so that they can be restored when the application is run again. This means that you must restore the settings before exiting the application. However, because the shortcuts for accessibility features can disrupt game play if triggered accidentally, you should turn off an accessibility shortcut only when that feature is not enabled by calling SystemParametersInfo.Īn accessibility shortcut that is turned off by SystemParametersInfo remains turned off even after the application has exited. The accessibility features are required for some customers and do not themselves interfere with full-screen games therefore, you should not change the accessibility settings. This, of course, can have a drastic effect on game play. When the shortcut is triggered, Windows (by default) presents a warning in a dialog box, which would cause Windows to minimize a game running in full-screen mode. If the SHIFT key is also used in the game, the user could accidentally trigger this shortcut during game play. For example, the StickyKeys shortcut is triggered by pressing the SHIFT key five times. Each of these accessibility features also has a keyboard shortcut that allows the feature to be turned on or off. Each of these serves a different purpose StickyKeys for example, is designed for people who have difficulty holding down two or more keys simultaneously. Windows includes accessibility features such as StickyKeys, FilterKeys, and ToggleKeys (see Windows Accessibility). so you control the fullscreen toggling in your application. Remember to use DXGI_MWA_NO_ALT_ENTER when you call the DXGI method MakeWindowAssociation g_bFullscreen is used to control if the Windows key is filtered by the keyboard hook or not. Implement the classic ALT+ENTER fullscreen toggle g_bWindowActive is used to control if the Windows key is filtered by the keyboard hook or not. 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. Disable the Accessibility Shortcut Keysĭisable the Windows Key with a Keyboard Hook.Disable the Windows Key with a Keyboard Hook.This article describes how to do the following: To avoid these issues, you should disable these keys when running in full-screen mode, and either enable the keys back to their default handlers when running in windowed mode or exit the application. 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.
0 Comments
Leave a Reply. |