-
Notifications
You must be signed in to change notification settings - Fork 0
/
disable-office-hotkeys.wh.cpp
52 lines (44 loc) · 1.66 KB
/
disable-office-hotkeys.wh.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ==WindhawkMod==
// @id disable-office-hotkeys
// @name Disable Office Hotkeys
// @description Disables the office hotkeys (Ctrl+Shift+Alt+Win combinations) in Windows
// @version 1.0.0
// @author ItsProfessional
// @github https://github.com/ItsProfessional
// @include explorer.exe
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
# Disable Office Hotkeys
This mod disables the office hotkeys (Ctrl+Shift+Alt+Win combinations) in Windows.
*/
// ==/WindhawkModReadme==
const UINT office_hotkeys[10] = { 0x57, 0x54, 0x59, 0x4F, 0x50, 0x44, 0x4C, 0x58, 0x4E, 0x20 }; // W, T, Y, O, P, D, L, X, N, SPACEBAR
BOOL(*pOriginalRegisterHotKey)(HWND hWnd, int id, UINT fsModifiers, UINT vk);
BOOL RegisterHotKeyHook(HWND hWnd, int id, UINT fsModifiers, UINT vk)
{
if (fsModifiers == (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN | MOD_NOREPEAT) && (
!vk
|| 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 pOriginalRegisterHotKey(hWnd, id, fsModifiers, vk);
}
BOOL Wh_ModInit() {
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* origFunc = (void*)GetProcAddress(hUser32, "RegisterHotKey");
Wh_SetFunctionHook(origFunc, (void*)RegisterHotKeyHook, (void**)&pOriginalRegisterHotKey);
return TRUE;
}