From befa3eaeb4961db70eb35ac2b8211477da54ee39 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Fri, 14 Jan 2022 00:13:02 +0200 Subject: [PATCH] Option to disable `Office` hotkeys (`Ctrl`+`Alt`+`Shift`+`Windows` key combinations) (#661) (.4) --- CHANGELOG.md | 1 + ExplorerPatcher/dllmain.c | 40 ++++++++++++++++++++++++++++++++++++ ExplorerPatcher/settings.reg | 2 ++ version.h | 6 +++--- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af7ca2..7f6bbf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Tested on OS build 22000.376. * Ability to choose a Windows 10 or Windows 11 Start button style for the Windows 10 taskbar (#436, thanks @krlvm) * Support for screen readers in the Properties window (#627) (.1) +* Option to disable `Office` hotkeys (`Ctrl`+`Alt`+`Shift`+`Windows` key combinations) (#661) (.4) #### Feature enhancements diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 98d4545..42f1e79 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -81,6 +81,7 @@ BOOL bDoNotRedirectSystemToSettingsApp = FALSE; BOOL bDoNotRedirectProgramsAndFeaturesToSettingsApp = FALSE; BOOL bDoNotRedirectDateAndTimeToSettingsApp = FALSE; BOOL bDoNotRedirectNotificationIconsToSettingsApp = FALSE; +BOOL bDisableOfficeHotkeys = FALSE; #define TASKBARGLOMLEVEL_DEFAULT 2 #define MMTASKBARGLOMLEVEL_DEFAULT 2 DWORD dwTaskbarGlomLevel = TASKBARGLOMLEVEL_DEFAULT; @@ -4460,6 +4461,15 @@ void WINAPI LoadSettings(LPARAM lParam) &bDoNotRedirectNotificationIconsToSettingsApp, &dwSize ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("DisableOfficeHotkeys"), + 0, + NULL, + &bDisableOfficeHotkeys, + &dwSize + ); dwTemp = TASKBARGLOMLEVEL_DEFAULT; dwSize = sizeof(DWORD); RegQueryValueExW( @@ -6253,6 +6263,30 @@ BOOL explorer_SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom) #pragma endregion +#pragma region "Disable Office Hotkeys" +const UINT office_hotkeys[10] = { 0x57, 0x54, 0x59, 0x4F, 0x50, 0x44, 0x4C, 0x58, 0x4E, 0x20 }; +BOOL explorer_RegisterHotkeyHook(HWND hWnd, int id, UINT fsModifiers, UINT vk) +{ + if (fsModifiers == (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN | MOD_NOREPEAT) && ( + vk == office_hotkeys[0] || + vk == office_hotkeys[1] || + vk == office_hotkeys[2] || + vk == office_hotkeys[3] || + vk == office_hotkeys[4] || + vk == office_hotkeys[5] || + vk == office_hotkeys[6] || + vk == office_hotkeys[7] || + vk == office_hotkeys[8] || + vk == office_hotkeys[9])) + { + SetLastError(ERROR_HOTKEY_ALREADY_REGISTERED); + return FALSE; + } + return RegisterHotKey(hWnd, id, fsModifiers, vk); +} +#pragma endregion + + DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall) { //Sleep(150); @@ -7010,6 +7044,12 @@ DWORD Inject(BOOL bIsExplorer) printf("Open Start on monitor thread\n"); + if (bDisableOfficeHotkeys) + { + VnPatchIAT(hExplorer, "user32.dll", "RegisterHotKey", explorer_RegisterHotkeyHook); + } + + if (bEnableArchivePlugin) { ArchiveMenuThreadParams* params = calloc(1, sizeof(ArchiveMenuThreadParams)); diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 417bad6..1ca9fc0 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -360,6 +360,8 @@ "PropertiesInWinX"=dword:00000000 ;b Remove shortcut key from program settings item in Win+X menu "NoMenuAccelerator"=dword:00000000 +;b Disable Office hotkeys (Ctrl+Alt+Shift+Windows key combinations) * +"DisableOfficeHotkeys"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] ;c 6 Default action in the Alt+F4 dialog on the desktop ;x 256 Switch user diff --git a/version.h b/version.h index d5b1a80..c399621 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22000 #define VER_MINOR 376 #define VER_BUILD_HI 41 -#define VER_BUILD_LO 3 +#define VER_BUILD_LO 4 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22000.376.41.3" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.376.41.3" +#define VER_FILE_STRING VALUE "FileVersion", "22000.376.41.4" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.376.41.4"