public void Start(IntPtr windowHandle) { UnregisterHotkey(windowHandle); var modifier = 0; if (ControlNeeded) { modifier |= KeyboardApi.MOD_CONTROL; } if (NoRepeat) { modifier |= KeyboardApi.MOD_NOREPEAT; } var registrationResult = KeyboardApi.RegisterHotKey( windowHandle, InterceptionId, modifier, KeyCode); if (!registrationResult) { throw new InvalidOperationException($"Couldn't install the hotkey interceptor for key {KeyCode}."); } }
bool UnregisterHotkey(IntPtr windowHandle) { return(KeyboardApi.UnregisterHotKey( windowHandle, InterceptionId)); }