コード例 #1
0
 public bool UnregisterHotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     if (this.windowHandle != null)
     {
         int hotKeyID = this.GetHotKeyID(modifiers, key);
         if (this.registeredHotKeys.Contains(hotKeyID))
         {
             this.registeredHotKeys.Remove(hotKeyID);
             return(UnregisterHotKey(this.windowHandle, hotKeyID));
         }
     }
     return(false);
 }
コード例 #2
0
 public bool RegisterHotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     if (this.windowHandle != null)
     {
         int hotKeyID = this.GetHotKeyID(modifiers, key);
         if (!this.registeredHotKeys.Contains(hotKeyID))
         {
             this.registeredHotKeys.Add(hotKeyID);
             return(RegisterHotKey(this.windowHandle, hotKeyID, (uint)modifiers, (uint)this.ConvertScanCodeToVirtualKey(key)));
         }
     }
     return(false);
 }
コード例 #3
0
        public void KeyUp(InputKeyEnum key)
        {
            InputContainer input = new InputContainer {
                Type = INPUT_KEYBOARD
            };

            input.Data.Keyboard = new KeyboardInput()
            {
                Scan = (ushort)key, Flags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE
            };
            InputContainer[] inputs = new InputContainer[] { input };
            uint             result = SendInput(1, inputs, Marshal.SizeOf(typeof(InputContainer)));
        }
コード例 #4
0
        public void KeyUp(InputKeyEnum key)
        {
            InputContainer input = new InputContainer {
                Type = INPUT_KEYBOARD
            };

            input.Data.Keyboard = new KeyboardInput()
            {
                Scan = (ushort)key, Flags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE
            };
            if (key == InputKeyEnum.Up || key == InputKeyEnum.Down || key == InputKeyEnum.Left || key == InputKeyEnum.Right)
            {
                input.Data.Keyboard.Flags |= KEYEVENTF_EXTENDEDKEY;
            }
            InputContainer[] inputs = new InputContainer[] { input };
            uint             result = SendInput(1, inputs, Marshal.SizeOf(typeof(InputContainer)));
        }
コード例 #5
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            try
            {
                if (msg == WINDOWS_MESSAGE_HOTKEY)
                {
                    int hotKeyID = wParam.ToInt32();
                    if (this.registeredHotKeys.Contains(hotKeyID))
                    {
                        int virtualKey = (((int)lParam >> 16) & 0xFFFF);

                        InputKeyEnum        key       = this.ConvertVirtualKeyToScanCode(virtualKey);
                        HotKeyModifiersEnum modifiers = (HotKeyModifiersEnum)((int)lParam & 0xFFFF);

                        this.HotKeyPressed?.Invoke(this, new HotKey(modifiers, key));
                    }
                }
            }
            catch (Exception ex) { Logger.Log(ex); }
            return(IntPtr.Zero);
        }
コード例 #6
0
ファイル: IInputService.cs プロジェクト: Sanw0/mixer-mixitup
 public HotKeyConfiguration(HotKeyModifiersEnum modifiers, InputKeyEnum key, Guid commandID)
     : base(modifiers, key)
 {
     this.CommandID = commandID;
 }
コード例 #7
0
ファイル: IInputService.cs プロジェクト: Sanw0/mixer-mixitup
 public HotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     this.Modifiers = modifiers;
     this.Key       = key;
 }
コード例 #8
0
 private int ConvertScanCodeToVirtualKey(InputKeyEnum key)
 {
     return(MapVirtualKey((uint)key, 3));
 }
コード例 #9
0
 private int GetHotKeyID(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     return((this.ConvertScanCodeToVirtualKey(key) << 16) | (int)modifiers);
 }
コード例 #10
0
 public InputAction(InputKeyEnum key, InputActionTypeEnum actionType, bool shift, bool control, bool alt)
     : this(actionType, shift, control, alt)
 {
     this.Key = key;
 }