Ejemplo n.º 1
0
        public static string GetDescription(HotKeySettings Settings)
        {
            if (Settings == null || Settings.KeyCode == null)
                return LocalizationProvider.Instance.GetTextValue("CorePlugins.HotKey.Description");

            // Create string to store key combination and final output description
            string strKeyCombo = "";
            string strFormattedOutput = LocalizationProvider.Instance.GetTextValue("CorePlugins.HotKey.SpecificDescription");

            // Build output string
            if (Settings.Windows)
                strKeyCombo = "Win + ";

            if (Settings.Control)
                strKeyCombo += "Ctrl + ";

            if (Settings.Alt)
                strKeyCombo += "Alt + ";

            if (Settings.Shift)
                strKeyCombo += "Shift + ";
            if (Settings.KeyCode.Count != 0)
            {
                foreach (var k in Settings.KeyCode)
                    strKeyCombo += GetKeyName(k) + " + ";
            }
            strKeyCombo = strKeyCombo.TrimEnd(' ', '+');

            // Return final formatted string
            return String.Format(strFormattedOutput, strKeyCombo);
        }
Ejemplo n.º 2
0
        public string Serialize()
        {
            if (_GUI != null)
            {
                _Settings = _GUI.Settings;
            }

            if (_Settings == null)
            {
                _Settings = new HotKeySettings();
            }

            return(PluginHelper.SerializeSettings(_Settings));
        }
Ejemplo n.º 3
0
        public static string GetDescription(HotKeySettings Settings)
        {
            if (Settings == null || Settings.KeyCode == null)
            {
                return(LocalizationProvider.Instance.GetTextValue("CorePlugins.HotKey.Description"));
            }

            // Create string to store key combination and final output description
            string strKeyCombo        = "";
            string strFormattedOutput = LocalizationProvider.Instance.GetTextValue("CorePlugins.HotKey.SpecificDescription");

            // Build output string
            if (Settings.Windows)
            {
                strKeyCombo = "Win + ";
            }

            if (Settings.Control)
            {
                strKeyCombo += "Ctrl + ";
            }

            if (Settings.Alt)
            {
                strKeyCombo += "Alt + ";
            }

            if (Settings.Shift)
            {
                strKeyCombo += "Shift + ";
            }
            if (Settings.KeyCode.Count != 0)
            {
                foreach (var k in Settings.KeyCode)
                {
                    strKeyCombo += GetKeyName(k) + " + ";
                }
            }
            strKeyCombo = strKeyCombo.TrimEnd(' ', '+');

            // Return final formatted string
            return(String.Format(strFormattedOutput, strKeyCombo));
        }
Ejemplo n.º 4
0
        private void SendShortcutKeys(HotKeySettings settings)
        {
            if (settings == null)
            {
                return;
            }
            if (settings.Windows &&
                settings.KeyCode.Count != 0 && settings.KeyCode[0] == Keys.L)
            {
                LockWorkStation();
                return;
            }

            if (settings.SendByKeybdEvent)
            {
                // Create keyboard keys to represent hot key combinations
                KeyboardKey winKey     = new KeyboardKey(Keys.LWin);
                KeyboardKey controlKey = new KeyboardKey(Keys.LControlKey);
                KeyboardKey altKey     = new KeyboardKey(Keys.LMenu);
                KeyboardKey shiftKey   = new KeyboardKey(Keys.LShiftKey);

                // Deceide which keys to press
                // Windows
                if (settings.Windows)
                {
                    winKey.Press();
                }

                // Control
                if (settings.Control)
                {
                    controlKey.Press();
                }

                // Alt
                if (settings.Alt)
                {
                    altKey.Press();
                }

                // Shift
                if (settings.Shift)
                {
                    shiftKey.Press();
                }

                // Modifier
                if (settings.KeyCode != null)
                {
                    foreach (var k in settings.KeyCode)
                    {
                        KeyboardKey modifierKey = new KeyboardKey(k);
                        if (!String.IsNullOrEmpty(modifierKey.KeyName))
                        {
                            modifierKey.PressAndRelease();
                        }
                    }
                }
                // Release Shift
                if (settings.Shift)
                {
                    shiftKey.Release();
                }

                // Release Alt
                if (settings.Alt)
                {
                    altKey.Release();
                }

                // Release Control
                if (settings.Control)
                {
                    controlKey.Release();
                }

                // Release Windows
                if (settings.Windows)
                {
                    winKey.Release();
                }
            }
            else
            {
                InputSimulator simulator = new InputSimulator();

                // Deceide which keys to press
                // Windows
                if (settings.Windows)
                {
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LWIN).Sleep(30);
                }

                // Control
                if (settings.Control)
                {
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LCONTROL).Sleep(30);
                }

                // Alt
                if (settings.Alt)
                {
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LMENU).Sleep(30);
                }

                // Shift
                if (settings.Shift)
                {
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LSHIFT).Sleep(30);
                }

                // Modifier
                if (settings.KeyCode != null)
                {
                    foreach (var k in settings.KeyCode)
                    {
                        if (!Enum.IsDefined(typeof(VirtualKeyCode), k.GetHashCode()))
                        {
                            continue;
                        }

                        var key = (VirtualKeyCode)k;
                        simulator.Keyboard.KeyPress(key).Sleep(30);
                    }
                }
                // Release Shift
                if (settings.Shift)
                {
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LSHIFT).Sleep(30);
                }

                // Release Alt
                if (settings.Alt)
                {
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LMENU).Sleep(30);
                }

                // Release Control
                if (settings.Control)
                {
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LCONTROL).Sleep(30);
                }

                // Release Windows
                if (settings.Windows)
                {
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LWIN).Sleep(30);
                }
            }
        }
Ejemplo n.º 5
0
        private void SendShortcutKeys(HotKeySettings settings)
        {
            if (settings.SendByKeybdEvent)
            {
                // Create keyboard keys to represent hot key combinations
                KeyboardKey winKey     = new KeyboardKey(Keys.LWin);
                KeyboardKey controlKey = new KeyboardKey(Keys.LControlKey);
                KeyboardKey altKey     = new KeyboardKey(Keys.LMenu);
                KeyboardKey shiftKey   = new KeyboardKey(Keys.LShiftKey);

                // Deceide which keys to press
                // Windows
                if (settings.Windows)
                {
                    winKey.Press();
                }

                // Control
                if (settings.Control)
                {
                    controlKey.Press();
                }

                // Alt
                if (settings.Alt)
                {
                    altKey.Press();
                }

                // Shift
                if (settings.Shift)
                {
                    shiftKey.Press();
                }

                // Modifier
                if (settings.KeyCode != null)
                {
                    foreach (var k in settings.KeyCode)
                    {
                        KeyboardKey modifierKey = new KeyboardKey(k);
                        if (!String.IsNullOrEmpty(modifierKey.KeyName))
                        {
                            modifierKey.PressAndRelease();
                        }
                    }
                }
                // Release Shift
                if (settings.Shift)
                {
                    shiftKey.Release();
                }

                // Release Alt
                if (settings.Alt)
                {
                    altKey.Release();
                }

                // Release Control
                if (settings.Control)
                {
                    controlKey.Release();
                }

                // Release Windows
                if (settings.Windows)
                {
                    winKey.Release();
                }
            }
            else
            {
                InputSimulator        simulator    = new InputSimulator();
                List <VirtualKeyCode> modifiedKeys = new List <VirtualKeyCode>();
                List <VirtualKeyCode> keys         = new List <VirtualKeyCode>();

                if (settings.KeyCode != null)
                {
                    foreach (var k in settings.KeyCode)
                    {
                        if (!Enum.IsDefined(typeof(VirtualKeyCode), k.GetHashCode()))
                        {
                            continue;
                        }

                        var key = (VirtualKeyCode)k;
                        keys.Add(key);
                    }
                }

                if (settings.Windows)
                {
                    modifiedKeys.Add(VirtualKeyCode.LWIN);
                }
                if (settings.Control)
                {
                    modifiedKeys.Add(VirtualKeyCode.LCONTROL);
                }
                if (settings.Alt)
                {
                    modifiedKeys.Add(VirtualKeyCode.LMENU);
                }
                if (settings.Shift)
                {
                    modifiedKeys.Add(VirtualKeyCode.LSHIFT);
                }

                if (modifiedKeys.Count == 0)
                {
                    if (keys.Count != 0)
                    {
                        simulator.Keyboard.KeyPress(keys.ToArray()).Sleep(30);
                    }
                }
                else
                {
                    if (keys.Count != 0)
                    {
                        simulator.Keyboard.ModifiedKeyStroke(modifiedKeys, keys).Sleep(30);
                    }
                    else
                    {
                        simulator.Keyboard.KeyPress(modifiedKeys.ToArray()).Sleep(30);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void SendKeysSeparately(HotKeySettings settings)
        {
            InputSimulator simulator = new InputSimulator();

            // Deceide which keys to press
            // Windows
            if (settings.Windows)
            {
                simulator.Keyboard.KeyDown(VirtualKeyCode.LWIN).Sleep(30);
            }

            // Control
            if (settings.Control)
            {
                simulator.Keyboard.KeyDown(VirtualKeyCode.LCONTROL).Sleep(30);
            }

            // Alt
            if (settings.Alt)
            {
                simulator.Keyboard.KeyDown(VirtualKeyCode.LMENU).Sleep(30);
            }

            // Shift
            if (settings.Shift)
            {
                simulator.Keyboard.KeyDown(VirtualKeyCode.LSHIFT).Sleep(30);
            }

            // Modifier
            if (settings.KeyCode != null)
            {
                foreach (var k in settings.KeyCode)
                {
                    if (!Enum.IsDefined(typeof(VirtualKeyCode), k.GetHashCode()))
                    {
                        continue;
                    }

                    var key = (VirtualKeyCode)k;
                    simulator.Keyboard.KeyPress(key).Sleep(30);
                }
            }
            // Release Shift
            if (settings.Shift)
            {
                simulator.Keyboard.KeyUp(VirtualKeyCode.LSHIFT).Sleep(30);
            }

            // Release Alt
            if (settings.Alt)
            {
                simulator.Keyboard.KeyUp(VirtualKeyCode.LMENU).Sleep(30);
            }

            // Release Control
            if (settings.Control)
            {
                simulator.Keyboard.KeyUp(VirtualKeyCode.LCONTROL).Sleep(30);
            }

            // Release Windows
            if (settings.Windows)
            {
                simulator.Keyboard.KeyUp(VirtualKeyCode.LWIN).Sleep(30);
            }
        }
Ejemplo n.º 7
0
        private void SendShortcutKeys(HotKeySettings settings)
        {
            if (settings == null)
                return;
            if (settings.Windows &&
              settings.KeyCode.Count != 0 && settings.KeyCode[0] == Keys.L)
            {
                LockWorkStation();
                return;
            }

            if (settings.SendByKeybdEvent)
            {

                // Create keyboard keys to represent hot key combinations
                KeyboardKey winKey = new KeyboardKey(Keys.LWin);
                KeyboardKey controlKey = new KeyboardKey(Keys.LControlKey);
                KeyboardKey altKey = new KeyboardKey(Keys.LMenu);
                KeyboardKey shiftKey = new KeyboardKey(Keys.LShiftKey);

                // Deceide which keys to press
                // Windows
                if (settings.Windows)
                    winKey.Press();

                // Control
                if (settings.Control)
                    controlKey.Press();

                // Alt
                if (settings.Alt)
                    altKey.Press();

                // Shift
                if (settings.Shift)
                    shiftKey.Press();

                // Modifier
                if (settings.KeyCode != null)
                    foreach (var k in settings.KeyCode)
                    {
                        KeyboardKey modifierKey = new KeyboardKey(k);
                        if (!String.IsNullOrEmpty(modifierKey.KeyName))
                            modifierKey.PressAndRelease();
                    }
                // Release Shift
                if (settings.Shift)
                    shiftKey.Release();

                // Release Alt
                if (settings.Alt)
                    altKey.Release();

                // Release Control
                if (settings.Control)
                    controlKey.Release();

                // Release Windows
                if (settings.Windows)
                    winKey.Release();
            }
            else
            {

                InputSimulator simulator = new InputSimulator();

                // Deceide which keys to press
                // Windows
                if (settings.Windows)
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LWIN);

                // Control
                if (settings.Control)
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LCONTROL);

                // Alt
                if (settings.Alt)
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LMENU);

                // Shift
                if (settings.Shift)
                    simulator.Keyboard.KeyDown(VirtualKeyCode.LSHIFT);

                // Modifier
                if (settings.KeyCode != null)
                    foreach (var k in settings.KeyCode)
                    {
                        if (!Enum.IsDefined(typeof(VirtualKeyCode), k.GetHashCode())) continue;

                        var key = (VirtualKeyCode)k;
                        simulator.Keyboard.KeyPress(key).Sleep(30);
                    }
                // Release Shift
                if (settings.Shift)
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LSHIFT);

                // Release Alt
                if (settings.Alt)
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LMENU);

                // Release Control
                if (settings.Control)
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LCONTROL);

                // Release Windows
                if (settings.Windows)
                    simulator.Keyboard.KeyUp(VirtualKeyCode.LWIN);
            }
        }
Ejemplo n.º 8
0
        public string Serialize()
        {
            if (_GUI != null)
                _Settings = _GUI.Settings;

            if (_Settings == null)
                _Settings = new HotKeySettings();

            return PluginHelper.SerializeSettings(_Settings);
        }