private void IsThreadHandleKeyboard(uint wParam, KBDLLHOOKSTRUCT keyboardStruct) { int code = (int)wParam; switch (code) { case WM_SYSKEYDOWN: case WM_KEYDOWN: { if (keyboardStruct.scanCode == 0) { ISLogger.Write("Cannot get scancode for virtual key {0}", keyboardStruct.vkCode); return; } if (keyboardStruct.scanCode == (int)ScanCode.Control) { currentModifiers |= Hotkey.Modifiers.Ctrl; } else if (keyboardStruct.scanCode == (int)ScanCode.Alt) { currentModifiers |= Hotkey.Modifiers.Alt; } else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift) { currentModifiers |= Hotkey.Modifiers.Shift; } Hotkey[] list = hotkeyList.ToArray(); for (int i = 0; i < list.Length; i++) { if ((keyboardStruct.scanCode == (short)list[i].HkScan) && (currentModifiers == list[i].Mods)) { if (list[i] is ClientHotkey) { ClientHotkey hk = list[i] as ClientHotkey; ClientHotkeyPressed?.Invoke(this, hk); } else if (list[i] is FunctionHotkey) { FunctionHotkey hk = list[i] as FunctionHotkey; FunctionHotkeyPressed?.Invoke(this, hk); } } } kbData = new ISInputData(ISInputCode.IS_KEYDOWN, (short)keyboardStruct.scanCode, 0); break; } case WM_SYSKEYUP: case WM_KEYUP: { if (keyboardStruct.scanCode == (int)ScanCode.Control) { currentModifiers &= ~Hotkey.Modifiers.Ctrl; } else if (keyboardStruct.scanCode == (int)ScanCode.Alt) { currentModifiers &= ~Hotkey.Modifiers.Alt; } else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift) { currentModifiers &= ~Hotkey.Modifiers.Shift; } kbData = new ISInputData(ISInputCode.IS_KEYUP, (short)keyboardStruct.scanCode, 0); break; } default: { ISLogger.Write("Unexpected windows keyboard input code " + code); return; } } if (UserInputBlocked) { InputReceived?.Invoke(this, kbData); } }
protected void OnClientHotkeyPressed(Guid client) { ClientHotkeyPressed?.Invoke(this, client); }