コード例 #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
        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);
        }
コード例 #4
0
        private async void AddHotKeyButton_Click(object sender, RoutedEventArgs e)
        {
            await this.Window.RunAsyncOperation(async() =>
            {
                if (this.CommandNameComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A command must be selected");
                    return;
                }

                CommandBase command = (CommandBase)this.CommandNameComboBox.SelectedItem;

                if (this.KeyComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A hot key configuration must be set");
                    return;
                }

                HotKeyModifiersEnum modifiers = HotKeyModifiersEnum.None;
                if (this.ShiftCheckBox.IsChecked.GetValueOrDefault())
                {
                    modifiers |= HotKeyModifiersEnum.Shift;
                }
                if (this.ControlCheckBox.IsChecked.GetValueOrDefault())
                {
                    modifiers |= HotKeyModifiersEnum.Control;
                }
                if (this.AltCheckBox.IsChecked.GetValueOrDefault())
                {
                    modifiers |= HotKeyModifiersEnum.Alt;
                }
                HotKeyConfiguration hotKey = new HotKeyConfiguration(modifiers, EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.KeyComboBox.SelectedItem), command.ID);

                ChannelSession.Settings.HotKeys[hotKey.ToString()] = hotKey;

                ChannelSession.Services.InputService.RegisterHotKey(hotKey.Modifiers, hotKey.Key);

                this.RefreshList();
            });
        }
コード例 #5
0
ファイル: IInputService.cs プロジェクト: Sanw0/mixer-mixitup
 public HotKeyConfiguration(HotKeyModifiersEnum modifiers, InputKeyEnum key, Guid commandID)
     : base(modifiers, key)
 {
     this.CommandID = commandID;
 }
コード例 #6
0
ファイル: IInputService.cs プロジェクト: Sanw0/mixer-mixitup
 public HotKey(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     this.Modifiers = modifiers;
     this.Key       = key;
 }
コード例 #7
0
 private int GetHotKeyID(HotKeyModifiersEnum modifiers, InputKeyEnum key)
 {
     return((this.ConvertScanCodeToVirtualKey(key) << 16) | (int)modifiers);
 }