mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-22 16:08:00 +08:00
670033c4da
* [Launcher/Settings] Low Level Keyboard Hooks * [Run] LowLevel Keyboard Hook for Hotkeys * Prevent shortcuts from auto repeating when keeping the keys pressed down
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#pragma once
|
|
#include <Windows.h>
|
|
#include "KeyboardHook.h"
|
|
|
|
namespace interop
|
|
{
|
|
public
|
|
ref struct Hotkey
|
|
{
|
|
bool Win;
|
|
bool Ctrl;
|
|
bool Shift;
|
|
bool Alt;
|
|
unsigned char Key;
|
|
|
|
Hotkey()
|
|
{
|
|
Win = false;
|
|
Ctrl = false;
|
|
Shift = false;
|
|
Alt = false;
|
|
Key = 0;
|
|
}
|
|
};
|
|
|
|
public
|
|
delegate void HotkeyCallback();
|
|
|
|
typedef unsigned short HOTKEY_HANDLE;
|
|
|
|
public
|
|
ref class HotkeyManager
|
|
{
|
|
public:
|
|
HotkeyManager();
|
|
~HotkeyManager();
|
|
|
|
HOTKEY_HANDLE RegisterHotkey(Hotkey ^ hotkey, HotkeyCallback ^ callback);
|
|
void UnregisterHotkey(HOTKEY_HANDLE handle);
|
|
|
|
private:
|
|
KeyboardHook ^ keyboardHook;
|
|
Dictionary<HOTKEY_HANDLE, HotkeyCallback ^> ^ hotkeys;
|
|
Hotkey ^ pressedKeys;
|
|
KeyboardEventCallback ^ keyboardEventCallback;
|
|
IsActiveCallback ^ isActiveCallback;
|
|
FilterKeyboardEvent ^ filterKeyboardCallback;
|
|
|
|
|
|
void KeyboardEventProc(KeyboardEvent ^ ev);
|
|
bool IsActiveProc();
|
|
bool FilterKeyboardProc(KeyboardEvent ^ ev);
|
|
HOTKEY_HANDLE GetHotkeyHandle(Hotkey ^ hotkey);
|
|
void UpdatePressedKeys(KeyboardEvent ^ ev);
|
|
void UpdatePressedKey(DWORD code, bool replaceWith, unsigned char replaceWithKey);
|
|
};
|
|
}
|