Ejemplo n.º 1
0
        private void ConfigForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            foreach (var hotKeyControl in keyBindings)
            {
                ;
                ((GlobalHotKey)keyList[Array.IndexOf(keyBindings, hotKeyControl)]).Enabled =
                    (hotKeyControl.Text != string.Empty);
            }


            KeyBinding.SaveConfig();
            hkm.RemoveHotKey("Start");
            hkm.RemoveHotKey("Stop");
            hkm.RemoveHotKey("Pause");
            hkm.RemoveHotKey("PitchUp");
            hkm.RemoveHotKey("PitchDown");
            foreach (GlobalHotKey k in keyList)
            {
                if (k.Enabled)
                {
                    hkm.AddGlobalHotKey(k);
                }
            }
            hkm.Enabled = true;
        }
Ejemplo n.º 2
0
        private void dlgCureBot_Loaded(object sender, RoutedEventArgs e)
        {
            _hotKeyManager = new HotKeyManager(this);
            _hotKeyManager.AddGlobalHotKey(_enableHK);

            _hotKeyManager.GlobalHotKeyPressed += new GlobalHotKeyEventHandler(hotKeyManager_GlobalHotKeyPressed);

            List <Character> monsters = new List <Character>();
            List <Character> fate     = new List <Character>();
            List <Character> players  = new List <Character>();

            MemoryFunctions.GetCharacters(monsters, fate, players, ref _user);

            if (_user.Job == JOB.WHM)
            {
                chk_TankPriority.IsChecked = true;
                chk_WHMMode.IsChecked      = true;
            }
            else
            {
                txt_CurePotency.Text = "750";
            }

            lst_StatusEffects.Items.Add("17");
            lst_StatusEffects.Items.Add("62");
            lst_StatusEffects.Items.Add("269");
            lst_StatusEffects.Items.Add("181");
            lst_StatusEffects.Items.Add("216");
        }
Ejemplo n.º 3
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            _hotKeyManager = new HotKeyManager(this);
            _hotKeyManager.AddGlobalHotKey(_enableHK);

            _hotKeyManager.GlobalHotKeyPressed += new GlobalHotKeyEventHandler(hotKeyManager_GlobalHotKeyPressed);

            Global.StunBotOpen = true;
        }
Ejemplo n.º 4
0
        void RegisterHotKeys()
        {
            MyHotKeyManager = new HotKeyManager(this);

            MyHotKeyManager.AddGlobalHotKey(ghkPlay);
            MyHotKeyManager.AddGlobalHotKey(ghkStop);
            MyHotKeyManager.AddGlobalHotKey(ghkFile);

            MyHotKeyManager.AddLocalHotKey(lhkPlay);
            MyHotKeyManager.AddLocalHotKey(lhkStop);
            MyHotKeyManager.AddLocalHotKey(lhkFile);
            MyHotKeyManager.AddLocalHotKey(lhkScreen);

            MyHotKeyManager.AddChordHotKey(chotPlay);
            MyHotKeyManager.AddChordHotKey(chotStop);
            MyHotKeyManager.AddChordHotKey(chotFile);

            MyHotKeyManager.GlobalHotKeyPressed += new GlobalHotKeyEventHandler(MyHotKeyManager_GlobalHotKeyPressed);
            MyHotKeyManager.LocalHotKeyPressed  += new LocalHotKeyEventHandler(MyHotKeyManager_LocalHotKeyPressed);
            MyHotKeyManager.ChordPressed        += new ChordHotKeyEventHandler(MyHotKeyManager_ChordPressed);
        }
Ejemplo n.º 5
0
        private void RegisterHotkey(HotKeyCombination combination, ref GlobalHotKey globalHotKey)
        {
            try
            {
                if (combination.IsInitialized)
                {
                    if (globalHotKey != null)
                    {
                        _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                    }

                    var k = Keys.ConvertFromWpfKey(combination.NormalKey);
                    globalHotKey = new GlobalHotKey(combination.Name, combination.ModifierKey, k);

                    _HotKeyManager.AddGlobalHotKey(globalHotKey);
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(e);
            }
        }
Ejemplo n.º 6
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            _hotKeyManager = new HotKeyManager(this);

            try
            {
                _hotKeyManager.AddGlobalHotKey(_enableHK);

                _hotKeyManager.GlobalHotKeyPressed += new GlobalHotKeyEventHandler(hotKeyManager_GlobalHotKeyPressed);
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to activate hotkeys. Make sure other bots are closed.", "Chocobot",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        private void RegisterHotKeyUp(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, KeyEventArgs e)
        {
            if (_disposed)
            {
                return;
            }

            try
            {
                var pressedKeys = Keys.GetPressdKeys();

                pressedKeys = Keys.ClearRepeatedKeys(pressedKeys);

                pressedKeys = Keys.ClearMousKeys(pressedKeys);

                if (pressedKeys.Length == 0)
                {
                    Keyboard.ClearFocus();

                    if (hotKeyCombination.IsInitialized)
                    {
                        if (globalHotKey != null)
                        {
                            _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                        }

                        var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey);
                        globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k);

                        _HotKeyManager.AddGlobalHotKey(globalHotKey);
                    }
                    else
                    {
                        if (globalHotKey != null)
                        {
                            _HotKeyManager.RemoveGlobalHotKey(globalHotKey);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
Ejemplo n.º 8
0
        void RegisterHotKeys()
        {
            ghkNotepad.Enabled   = chkNotepad.Checked;
            ghkWordpad.Enabled   = chkWordpad.Checked;
            ghkCalc.Enabled      = chkCalculator.Checked;
            ghkTaskMan.Enabled   = chkTaskManager.Checked;
            ghkUninstall.Enabled = chkUninstall.Checked;
            ghkCustom.Enabled    = chkCustomEnabled.Checked;

            lhkNewHotkey.Enabled   = chkNewHotKey.Checked;
            lhkNewLocalKey.Enabled = chkNewLocal.Checked;
            lhkCopyLog.Enabled     = chkCopyClipboard.Checked;
            lhkClearLog.Enabled    = chkCopyClipboard.Checked;
            lhkDisableLog.Enabled  = chkDisableLogging.Checked;

            //Store an information in the tag of the hotkeys.
            ghkNotepad.Tag   = "Notepad.exe";
            ghkWordpad.Tag   = "Wordpad.exe";
            ghkCalc.Tag      = "Calc.exe";
            ghkTaskMan.Tag   = "Taskmgr.exe";
            ghkUninstall.Tag = "appwiz.cpl";

            chotCmd.Tag        = "cmd.exe";
            chotPowerShell.Tag = "powershell.exe";
            chotIExplore.Tag   = "iexplore.exe";
            chotRegEdit.Tag    = "regedit.exe";
            chotCharMap.Tag    = "charmap.exe";

            lhkNewHotkey.HotKeyPressed += delegate { AddNewHotKey(); };

            //Now, we'll add the Keys to the HotKeyManager
            MyHotKeyManager.AddGlobalHotKey(ghkNotepad);
            MyHotKeyManager.AddGlobalHotKey(ghkWordpad);
            MyHotKeyManager.AddGlobalHotKey(ghkCalc);
            MyHotKeyManager.AddGlobalHotKey(ghkTaskMan);
            MyHotKeyManager.AddGlobalHotKey(ghkUninstall);
            MyHotKeyManager.AddGlobalHotKey(ghkCustom);
            //Add the Local HotKeys.
            MyHotKeyManager.AddLocalHotKey(lhkNewHotkey);
            MyHotKeyManager.AddLocalHotKey(lhkNewLocalKey);
            MyHotKeyManager.AddLocalHotKey(lhkCopyLog);
            MyHotKeyManager.AddLocalHotKey(lhkClearLog);
            MyHotKeyManager.AddLocalHotKey(lhkDisableLog);
            //Add the Chord HotKeys.
            MyHotKeyManager.AddChordHotKey(chotCmd);
            MyHotKeyManager.AddChordHotKey(chotPowerShell);
            MyHotKeyManager.AddChordHotKey(chotIExplore);
            MyHotKeyManager.AddChordHotKey(chotRegEdit);
            MyHotKeyManager.AddChordHotKey(chotCharMap);
        }
        private void ReRegisterGlobalHotekey(HotKeyManager hotKeyManager, ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination)
        {
            if (_disposed)
            {
                return;
            }
            if (globalHotKey != null)
            {
                hotKeyManager.RemoveGlobalHotKey(globalHotKey);
                globalHotKey = null;
            }

            if (hotKeyCombination.IsInitialized)
            {
                var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey);
                globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k);

                hotKeyManager.AddGlobalHotKey(globalHotKey);
            }
        }
Ejemplo n.º 10
0
 private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     _hotKeyManager = new HotKeyManager(this);
     _hotKeyManager.AddGlobalHotKey(_enableHK);
     _hotKeyManager.GlobalHotKeyPressed += hotKeyManager_GlobalHotKeyPressed;
 }
Ejemplo n.º 11
0
        private void InitHotKeyBiding()
        {
            try
            {
                hkm         = new HotKeyManager(this);
                hkm.Enabled = false;
                if (KeyBinding.hotkeyArrayList == null || KeyBinding.hotkeyArrayList.Count < 5)
                {
                    hotkeysArrayList = new ArrayList();
                    hotkeysArrayList.Clear();
                    hotkeysArrayList.Add(
                        new GlobalHotKey(
                            "Start", Modifiers.Control, Keys.F10, true));
                    hotkeysArrayList.Add(
                        new GlobalHotKey(
                            "Stop", Modifiers.Control, Keys.F11, true));
                    hotkeysArrayList.Add(
                        new GlobalHotKey(
                            "PitchUp", Modifiers.Control, Keys.F8, true));
                    hotkeysArrayList.Add(
                        new GlobalHotKey(
                            "PitchDown", Modifiers.Control, Keys.F9, true));
                    hotkeysArrayList.Add(
                        new GlobalHotKey(
                            "Pause", Modifiers.Control, Keys.F12, true));
                    KeyBinding.hotkeyArrayList = hotkeysArrayList;
                }
                else
                {
                    hotkeysArrayList = KeyBinding.hotkeyArrayList;
                }

                {
                    ((GlobalHotKey)hotkeysArrayList[0]).HotKeyPressed += Start_HotKeyPressed;
                    ((GlobalHotKey)hotkeysArrayList[1]).HotKeyPressed += Stop_HotKeyPressed;
                    ((GlobalHotKey)hotkeysArrayList[2]).HotKeyPressed += PitchUp_HotKeyPressed;
                    ((GlobalHotKey)hotkeysArrayList[3]).HotKeyPressed += PitchDown_HotKeyPressed;
                    ((GlobalHotKey)hotkeysArrayList[4]).HotKeyPressed += Pause_HotKeyPressed;
                }
                var ret = true;
                foreach (GlobalHotKey k in hotkeysArrayList)
                {
                    if (k.Enabled)
                    {
                        try
                        {
                            hkm.AddGlobalHotKey(k);
                        }
                        catch (Exception e)
                        {
                            ret = false;
                        }
                    }
                }

                if (ret == false)
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(new Form()
                {
                    TopMost = true
                },
                                $"部分快捷键注册失败,程序可能无法正常运行。\r\n请检查是否有其他程序占用。\r\n点击下方小齿轮重新配置快捷键",
                                "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                hkm.Enabled = true;
            }
        }