예제 #1
0
 public SelectAction(Hotkey hotkey)
 {
     InitializeComponent();
     _hotkey = hotkey;
     _actions = hotkey.Actions;
     _actionContainer = new ActionContainer();
 }
예제 #2
0
        /// <summary>
        ///     Add a Global Hotkey
        /// </summary>
        /// <param name="hotkey">Hotkey</param>
        /// <returns>True on success</returns>
        public bool Add(Hotkey hotkey)
        {
            int id = 0;
            // Add hotkey to settings
            try
            {
                Settings.Default.HotKeys.Add(hotkey);
                Logger.Instance.WriteGlobal("Register hotkey: {0} - {1}+{2}", hotkey.Name,
                    hotkey.Modifier.ToString().Replace(", ", "+"), hotkey.Key);
                id = _keyboardHook.RegisterHotKey(hotkey.Modifier, hotkey.Key);
                hotkey.HookId = id;

                foreach (Action action in hotkey.Actions)
                {
                    Debug.WriteLine("Initialize Hotkey: {0} {1}", action.Name, action.Version);
                    ActionContainer.GetAction(action.Name, action.Version).OnInitialize(hotkey);
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.WriteGlobal("Failed to register hotkey with message: " + ex.Message);
                DebugHelper.Exception(ex);
            }
            return id >= 1;
        }
예제 #3
0
 public NewHotkey(Hotkey hotkey)
 {
     InitializeComponent();
     Text = "Edit Hotkey";
     textBox1.Text = hotkey.Name;
     textBox2.Text = string.Format("{0}+{1}", hotkey.Modifier.ToString().Replace(", ", "+"), hotkey.Key);
     HotkeyNew = hotkey;
 }
예제 #4
0
        /// <summary>
        /// Binds a <see cref="Hotkey"/> to a <see cref="HotkeyCallback"/>.
        /// </summary>
        /// <exception cref="HotkeyAlreadyBoundException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public HotkeyCallback Bind(Hotkey hotkeyCombo)
        {
            if (hotkeyCombo == null)
                throw new ArgumentNullException("hotkeyCombo");

            HotkeyCallback callback = new HotkeyCallback();
            container.Add(hotkeyCombo, callback);
            RegisterHotkey(hotkeyCombo);

            return callback;
        }
예제 #5
0
        public static void Register(IWin32Window owner, int id, Hotkey hotkey)
        {
            if(hotkey == null) return;

            uint modifiers = 0;
            if(hotkey.Alt) modifiers |= 0x0001;
            if(hotkey.Control) modifiers |= 0x0002;
            if(hotkey.Shift) modifiers |= 0x0004;

            RegisterHotKey(owner.Handle, id, modifiers, (uint) hotkey.KeyCode);
        }
예제 #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Back)
            {
                Reset();
                return;
            }

            var converter = new HotkeyConverter();
            Hotkey = (Hotkey) converter.ConvertFrom(e.KeyData);
            RenderText();
        }
예제 #7
0
        public HotkeyHandle Map(Hotkey hotkey, HotkeyHandler action)
        {
            var mapping = new HotkeyMapping {
                Hotkey = hotkey,
                Action = action,
                Id = Interlocked.Increment(ref _idCounter)
            };

            _agent.AddMapping(mapping);

            return HotkeyHandle.Create(() => _agent.RemoveMappingByHotkey(hotkey));
        }
예제 #8
0
파일: HotkeysForm.cs 프로젝트: jlami/mutefm
        private void mOkButton_Click(object sender, EventArgs e)
        {
            List<Hotkey> hotkeyList = new List<Hotkey>();

            for (int i = 0; i < _hotkeyControls.Count; i++)
            {
                Hotkey hotkey = new Hotkey(_hotkeyControls[i].HotkeyName, _hotkeyControls[i].HotkeyEnabled, _hotkeyControls[i].HotkeyKey);
                hotkeyList.Add(hotkey);
            }
            SmartVolManagerPackage.BgMusicManager.MuteFmConfig.Hotkeys = hotkeyList.ToArray();
            MuteFmConfigUtil.Save(SmartVolManagerPackage.BgMusicManager.MuteFmConfig);
            this.Close();
        }
예제 #9
0
 ///<summary>
 ///  Call first
 ///</summary>
 public PathControl(PathProfile pathProfile)
 {
     InitializeComponent();
     DoubleBuffered = true;
     GraphView.BringToFront();
     _pathProfile = pathProfile;
     _pathLoadedThread = new Thread(LoadPath) {IsBackground = true};
     _pathLoadedThread.Start();
     if (LazySettings.SetupUseHotkeys)
     {
         _f7 = new Hotkey();
         _f7.KeyCode = Keys.F7;
         _f7.Windows = false;
         _f7.Pressed += delegate { AddSpot(); };
         try
         {
             if (!_f7.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F7 as hotkey");
             }
             else
             {
                 _f7.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F7 as hotkey");
         }
         _f8 = new Hotkey();
         _f8.KeyCode = Keys.F8;
         _f8.Windows = false;
         _f8.Pressed += delegate { AddNode(); };
         try
         {
             if (!_f8.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F8 as hotkey");
             }
             else
             {
                 _f8.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F8 as hotkey");
         }
     }
 }
예제 #10
0
        /// <summary>
        /// Indicates whether a <see cref="Hotkey"/> has been bound already either 
        /// by this application or another application.
        /// </summary>
        /// <param name="hotkeyCombo">
        /// The <see cref="Hotkey"/> to evaluate.
        /// </param>
        /// <returns>
        /// <c>true</c> if the <see cref="Hotkey"/> has not been previously bound 
        /// and is available to be bound; otherwise, <c>false</c>.
        /// </returns>
        public bool IsHotkeyAlreadyBound(Hotkey hotkeyCombo)
        {
            bool successful =
                NativeMethods.RegisterHotKey(
                    hotkeyWindow.Handle,
                    hotkeyCombo.GetHashCode(),
                    (uint)hotkeyCombo.Modifier,
                    (uint)hotkeyCombo.Key);

            if (!successful)
                return true;

            NativeMethods.UnregisterHotKey(
                hotkeyWindow.Handle,
                hotkeyCombo.GetHashCode());

            return false;
        }
예제 #11
0
        private void lbActions_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateHotkey();

            this.currentSelectedHotkey = lbActions.SelectedItem as Hotkey;

            txtHotkeyKeys.Text = this.currentSelectedHotkey.Shortcut;
        }
예제 #12
0
 private void Start()
 {
     if (_firstTime)
     {
         LoadFirstTime();
         _firstTime = false;
     }
     if (File.Exists(OurDirectory + "\\Rotations\\" + RotationSettings.LoadedRotationManager + ".xml"))
     {
         RotationManagerController = new RotationManagerController();
         RotationManagerController.Load(OurDirectory + "\\Rotations\\" + RotationSettings.LoadedRotationManager +
                                        ".xml");
     }
     foreach (Rotation rotation in RotationManagerController.Rotations.Where(r => r.Active))
     {
         try
         {
             CheckBuffAndKeys(rotation.Rules.GetRules);
             var hotkey = new Hotkey();
             hotkey.Windows = rotation.Windows;
             hotkey.Shift = rotation.Shift;
             hotkey.Alt = rotation.Alt;
             hotkey.Control = rotation.Ctrl;
             Rotation rotation1 = rotation;
             hotkey.KeyCode = (Keys) RotationSettings.KeysList.FirstOrDefault(k => k.Text == rotation1.Key).Code;
             hotkey.Pressed += delegate { StartRotation(rotation1.Name); };
             if (!hotkey.GetCanRegister(this))
             {
                 Logging.Write("Cannot register {0} as hotkey", rotation.Key);
             }
             else
             {
                 hotkey.Register(this);
                 _hotKeys.Add(hotkey);
             }
         }
         catch
         {
             Logging.Write("Cannot register {0} as hotkey", rotation.Key);
         }
     }
 }
예제 #13
0
 public CatchHotkey(NewHotkey parent)
 {
     InitializeComponent();
     _parent = parent;
     _hotkey = parent.HotkeyNew;
 }
예제 #14
0
        /// <summary>
        /// loads the HotKeys
        /// </summary>
        public void LoadHotKeys()
        {
            _hotkeyPlayPause = new Hotkey();
            _hotkeyStop = new Hotkey();
            _hotkeyNext = new Hotkey();
            _hotkeyPrev = new Hotkey();
            _hotkeyOverlay = new Hotkey();
            _hotkeyVolUp = new Hotkey();
            _hotkeyVolDown = new Hotkey();

            _hotkeyPlayPause.APlayControler = APlayControler;
            _hotkeyStop.APlayControler = APlayControler;
            _hotkeyNext.APlayControler = APlayControler;
            _hotkeyPrev.APlayControler = APlayControler;
            _hotkeyOverlay.APlayControler = APlayControler;
            _hotkeyVolUp.APlayControler = APlayControler;
            _hotkeyVolDown.APlayControler = APlayControler;

            _hotkeyPlayPause.SetHotkey(AConfiguration.HotkeyPlay.MAlt,
                                      AConfiguration.HotkeyPlay.MCtrl,
                                      AConfiguration.HotkeyPlay.MShift,
                                      false,
                                      AConfiguration.HotkeyPlay.HKey);

            _hotkeyNext.SetHotkey(AConfiguration.HotkeyNext.MAlt,
                                  AConfiguration.HotkeyNext.MCtrl,
                                  AConfiguration.HotkeyNext.MShift,
                                  false,
                                  AConfiguration.HotkeyNext.HKey);

            _hotkeyPrev.SetHotkey(AConfiguration.HotkeyPrev.MAlt,
                                      AConfiguration.HotkeyPrev.MCtrl,
                                      AConfiguration.HotkeyPrev.MShift,
                                      false,
                                      AConfiguration.HotkeyPrev.HKey);

            _hotkeyStop.SetHotkey(AConfiguration.HotkeyStop.MAlt,
                                      AConfiguration.HotkeyStop.MCtrl,
                                      AConfiguration.HotkeyStop.MShift,
                                      false,
                                      AConfiguration.HotkeyStop.HKey);

            _hotkeyOverlay.SetHotkey(AConfiguration.HotkeyOverlay.MAlt,
                                      AConfiguration.HotkeyOverlay.MCtrl,
                                      AConfiguration.HotkeyOverlay.MShift,
                                      false,
                                      AConfiguration.HotkeyOverlay.HKey);

            _hotkeyVolUp.SetHotkey(AConfiguration.HotkeyVolUp.MAlt,
                                      AConfiguration.HotkeyVolUp.MCtrl,
                                      AConfiguration.HotkeyVolUp.MShift,
                                      false,
                                      AConfiguration.HotkeyVolUp.HKey);

            _hotkeyVolDown.SetHotkey(AConfiguration.HotkeyVolDown.MAlt,
                                      AConfiguration.HotkeyVolDown.MCtrl,
                                      AConfiguration.HotkeyVolDown.MShift,
                                      false,
                                      AConfiguration.HotkeyVolDown.HKey);

            _hotkeyPlayPause.HotkeyPressed += HotkeyPlayPauseHotkeyPressed;
            _hotkeyStop.HotkeyPressed += HotkeyStopHotkeyPressed;
            _hotkeyNext.HotkeyPressed += HotkeyNextHotkeyPressed;
            _hotkeyPrev.HotkeyPressed += HotkeyPrevHotkeyPressed;
            _hotkeyOverlay.HotkeyPressed += HotkeyOverlayHotkeyPressed;
            _hotkeyVolUp.HotkeyPressed += HotkeyVolUpHotkeyPressed;
            _hotkeyVolDown.HotkeyPressed += HotkeyVolDownHotkeyPressed;

            try
            {
                _hotkeyPlayPause.Enabled = AConfiguration.HotkeyPlay.IsEnabled;
                _hotkeyStop.Enabled = AConfiguration.HotkeyStop.IsEnabled;
                _hotkeyNext.Enabled = AConfiguration.HotkeyNext.IsEnabled;
                _hotkeyPrev.Enabled = AConfiguration.HotkeyPrev.IsEnabled;
                _hotkeyOverlay.Enabled = AConfiguration.HotkeyOverlay.IsEnabled;
                _hotkeyVolUp.Enabled = AConfiguration.HotkeyVolUp.IsEnabled;
                _hotkeyVolDown.Enabled = AConfiguration.HotkeyVolDown.IsEnabled;
            }
            catch (HotkeyAlreadyInUseException)
            {
                //new Error("Could not register a hotkey (already in use).",_anAppHandle,false,this);
            }
        }
예제 #15
0
        private void UnregisterHotkey(Hotkey hotkeyCombo)
        {
            bool successful =
                NativeMethods.UnregisterHotKey(
                    hotkeyWindow.Handle,
                    hotkeyCombo.GetHashCode());

            if (!successful)
                throw new HotkeyNotBoundException(Marshal.GetLastWin32Error());
        }
예제 #16
0
        private Hotkey SetHotKey(Keys keys, bool shift, bool control, bool alt, bool windows, ClipboardInfo selectedInfo)
        {
            try
            {
                int index = selectedInfo.INDEX;

                Hotkey hk = new Hotkey();
                hk.KeyCode = keys;
                hk.Shift = shift;
                hk.Control = control;
                hk.Alt = alt;
                hk.Windows = windows;

                switch (index)
                {
                    case 1:
                        hk.Pressed += new HandledEventHandler(hk_Pressed1);
                        break;
                    case 2:
                        hk.Pressed += new HandledEventHandler(hk_Pressed2);
                        break;
                    case 3:
                        hk.Pressed += new HandledEventHandler(hk_Pressed3);
                        break;
                    case 4:
                        hk.Pressed += new HandledEventHandler(hk_Pressed4);
                        break;
                    case 5:
                        hk.Pressed += new HandledEventHandler(hk_Pressed5);
                        break;
                    case 6:
                        hk.Pressed += new HandledEventHandler(hk_Pressed6);
                        break;
                    case 7:
                        hk.Pressed += new HandledEventHandler(hk_Pressed7);
                        break;
                    case 8:
                        hk.Pressed += new HandledEventHandler(hk_Pressed8);
                        break;
                    case 9:
                        hk.Pressed += new HandledEventHandler(hk_Pressed9);
                        break;
                    case 10:
                        hk.Pressed += new HandledEventHandler(hk_Pressed0);
                        break;
                    default:
                        break;
                }

                if (hk.GetCanRegister(this))
                {
                    hk.Register(this);
                    return hk;
                }

                return null;
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return null;
            }
        }
예제 #17
0
        private void RegisterHotkey(Hotkey hotkeyCombo)
        {
            bool successful =
                NativeMethods.RegisterHotKey(
                    hotkeyWindow.Handle,
                    hotkeyCombo.GetHashCode(),
                    (uint)hotkeyCombo.Modifier,
                    (uint)hotkeyCombo.Key);

            if (!successful)
                throw new Win32Exception(Marshal.GetLastWin32Error());
        }
예제 #18
0
파일: Main.cs 프로젝트: civicacid/myevo
 private void RegisterHotKeys()
 {
     if (LazySettings.SetupUseHotkeys && !_hotKeysLoaded)
     {
         _f10 = new Hotkey();
         _f10.KeyCode = Keys.F10;
         _f10.Windows = false;
         _f10.Pressed += delegate { PauseBot(); };
         try
         {
             if (!_f10.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F10 as hotkey");
             }
             else
             {
                 _f10.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F10 as hotkey");
         }
         _f9 = new Hotkey();
         _f9.KeyCode = Keys.F9;
         _f9.Windows = false;
         _f9.Pressed += delegate { StartStopBotting(); };
         try
         {
             if (!_f9.GetCanRegister(this))
             {
                 Logging.Write("Cannot register F9 as hotkey");
             }
             else
             {
                 _f9.Register(this);
             }
         }
         catch
         {
             Logging.Write("Cannot register F9 as hotkey");
         }
         _hotKeysLoaded = true;
     }
 }
예제 #19
0
 private void ButtonClearOnClick(object sender, EventArgs e)
 {
     Hotkey = null;
 }
예제 #20
0
 public void RemoveMappingByHotkey(Hotkey hotkey)
 {
     for(var i = 0; i < _mappings.Count; i++) {
         if(_mappings[i].Hotkey == hotkey) {
             UnregisterMapping(_mappings[i]);
             _mappings.RemoveAt(i);
             break;
         }
     }
 }
 public void OnInitialize(Hotkey hotkey)
 {
     _hotkey = hotkey;
 }
예제 #22
0
 /// <summary>
 /// Unbinds a previously bound <see cref="Hotkey"/>.
 /// </summary>
 /// <exception cref="HotkeyNotBoundException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public void Unbind(Hotkey hotkeyCombo)
 {
     container.Remove(hotkeyCombo);
     UnregisterHotkey(hotkeyCombo);
 }
예제 #23
0
        public void Dispose()
        {
            if (null != _hotKey)
            {
                _hotKey.Dispose();
                _hotKey = null;
            }

            if (null != _notify)
            {
                _notify.Visible = false;
                _notify.Dispose();
                _notify = null;
            }
        }
예제 #24
0
 public NewHotkey()
 {
     InitializeComponent();
     HotkeyNew = new Hotkey();
 }
예제 #25
0
        // Récupération du raccourci de la hotkey
        private void registerHotkey(String raccourci, ref Hotkey hotkey, HotkeyMethodDelegate callback)
        {
            //Récupération et ajout des touches spéciales
            if (raccourci.Contains("CTRL"))
                hotkey.Control = true;
            if (raccourci.Contains("ALT"))
                hotkey.Alt = true;
            if (raccourci.Contains("MAJ"))
                hotkey.Shift = true;
            if (raccourci.Contains("WIN"))
                hotkey.Windows = true;

            //Récupération de la lettre
            String lettre = raccourci.Substring(raccourci.LastIndexOf("+") + 1);

            //Si lettre reconnue, ajout de celle-ci et enregistrement de la combinaison
            if (!Enum.IsDefined(typeof(Keys), lettre))
                afficheMessage("Hotkey", "Erreur de formatage du fichier de config");
            else
            {
                hotkey.KeyCode = (Keys)Enum.Parse(typeof(Keys), lettre, false);
                hotkey.Pressed += new System.ComponentModel.HandledEventHandler(callback);

                if (!hotkey.GetCanRegister(invokeControl))
                    afficheMessage("Hotkey", "Impossible d'enregistrer le raccourci");
                else
                    hotkey.Register(invokeControl);
            }
        }
예제 #26
0
        /// <summary>
        /// Activate CtrlCVMaster Shortcut Key
        /// </summary>
        public void ActivateShortcutKey(Keys keys, bool shift, bool control, bool alt, bool windows)
        {
            try
            {
                if (this.activateKey != null)
                    this.activateKey.Unregister();

                this.activateKey = new Hotkey();

                activateKey.KeyCode = keys;
                activateKey.Shift = shift;
                activateKey.Control = control;
                activateKey.Alt = alt;
                activateKey.Windows = windows;

                activateKey.Pressed += new HandledEventHandler(activateHk_Pressed);

                if (activateKey.GetCanRegister(this)) activateKey.Register(this);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
예제 #27
0
 private void TextBoxOnKeyDown(object sender, KeyEventArgs e)
 {
     Hotkey = Hotkey.FromEventArgs(e);
     e.SuppressKeyPress = true;
 }
예제 #28
0
 private void Reset()
 {
     Hotkey = new Hotkey(Modifiers.None, Keys.None);
     Text = "None";
 }
예제 #29
0
 /// <summary>
 ///     The internal method used to handle hotkeys that are pressed. This will subsequently call the Trigger method
 ///     provided the various checks and balances pass.
 /// </summary>
 private void KeyIsPressed(Hotkey hotKey)
 {
     // Ability Chain Check... placing a "Paws_" prefix ensures that no other registered hotkeys are messed with in the system.
     var abilityChain = AbilityChains.SingleOrDefault(o => "Paws_" + o.Name == hotKey.Name);
     if (abilityChain == null) return;
     if (StyxWoW.Me.Specialization == abilityChain.Specialization)
     {
         // We have a triggered Ability Chain
         Trigger(abilityChain);
     }
     else
     {
         Log.AbilityChain(
             string.Format(
                 "Hotkey detected, but your specialization must be {0} to trigger the {1} ability chain.",
                 abilityChain.Specialization.ToString().Replace("Druid", string.Empty), hotKey.Name));
     }
 }
예제 #30
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            this.TopMost = false;
            //skinEngine1.SkinFile = Application.StartupPath + @"\MacOS.ssk";

            notifyIcon1.Visible = false;
            Hotkey hotkey;
            hotkey = new Hotkey(this.Handle);
            //定义快键(Ctrl + F1)
            Hotkey1 = hotkey.RegisterHotkey(System.Windows.Forms.Keys.F12, Hotkey.KeyFlags.MOD_CONTROL);
            hotkey.OnHotkey += new HotkeyEventHandler(OnHotkey);
        }