forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
centralized_hotkeys.h
45 lines (35 loc) · 1.12 KB
/
centralized_hotkeys.h
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
#pragma once
#include <Windows.h>
#include <functional>
namespace CentralizedHotkeys
{
struct Action
{
std::wstring moduleName;
std::function<void(WORD, WORD)> action;
Action(std::wstring moduleName = L"", std::function<void(WORD, WORD)> action = ([](WORD modifiersMask, WORD vkCode) {}))
{
this->moduleName = moduleName;
this->action = action;
}
};
struct Shortcut
{
WORD modifiersMask;
WORD vkCode;
Shortcut(WORD modifiersMask = 0, WORD vkCode = 0)
{
this->modifiersMask = modifiersMask;
this->vkCode = vkCode;
}
bool operator<(const Shortcut& key) const
{
return std::pair<WORD, WORD>{ this->modifiersMask, this->vkCode } < std::pair<WORD, WORD>{ key.modifiersMask, key.vkCode };
}
};
std::wstring ToWstring(const Shortcut& shortcut);
bool AddHotkeyAction(Shortcut shortcut, Action action);
void UnregisterHotkeysForModule(std::wstring moduleName);
void PopulateHotkey(Shortcut shortcut);
void RegisterWindow(HWND hwnd);
}