Горячий элемент управления возвращает общедоступные новые ключи List:
Код: Выделить всё
var keyInfo = MainShortcut.Keys.Cast().ToList();
foreach (var item in keyInfo)
{
var virtKey = item.Key;
var keyName = item.KeyName;
}
Код: Выделить всё
public static bool RegisterHotkey(int hotkeyId, VirtualKeyModifiers modifiers, VirtualKey virtualKey)
{
// Get window handle
MainWindow window = App.MainWindow;
HWND hWnd = new(WindowNative.GetWindowHandle(window));
// Register hotkey
BOOL success = PInvoke.RegisterHotKey(hWnd, hotkeyId, HOT_KEY_MODIFIERS.MOD_NOREPEAT | (HOT_KEY_MODIFIERS)modifiers, (uint)virtualKey);
return success;
}
Минимальное воспроизведение: https://github.com/RyanLua/GlobalShortcut
Подробнее здесь: https://stackoverflow.com/questions/798 ... sterhotkey
Мобильная версия