Ejemplo n.º 1
0
        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}.");
            }
        }
Ejemplo n.º 2
0
 bool UnregisterHotkey(IntPtr windowHandle)
 {
     return(KeyboardApi.UnregisterHotKey(
                windowHandle, InterceptionId));
 }