示例#1
0
        public HotKeyUI()
        {
            InitializeComponent();

            this.TopLevel        = false;
            this.FormBorderStyle = FormBorderStyle.None;
            this.AutoScroll      = true;
            this.Dock            = DockStyle.Fill;

            this.txtKey.KeyDown           += new KeyEventHandler(txtKey_KeyDown);
            this.txtKey.GotFocus          += new EventHandler(txtKey_GotFocus);
            this.txtKey.LostFocus         += new EventHandler(txtKey_LostFocus);
            this.LLKeyHook.KeyIntercepted += new ManagedWinapi.Hooks.LowLevelKeyboardHook.KeyCallback(LLKeyHook_KeyIntercepted);

            _Settings = new HotKeySettings();
        }
示例#2
0
        public HotKeyUI()
        {
            InitializeComponent();

            this.TopLevel = false;
            this.FormBorderStyle = FormBorderStyle.None;
            this.AutoScroll = true;
            this.Dock = DockStyle.Fill;

            this.txtKey.KeyDown += new KeyEventHandler(txtKey_KeyDown);
            this.txtKey.GotFocus += new EventHandler(txtKey_GotFocus);
            this.txtKey.LostFocus += new EventHandler(txtKey_LostFocus);
            this.LLKeyHook.KeyIntercepted += new ManagedWinapi.Hooks.LowLevelKeyboardHook.KeyCallback(LLKeyHook_KeyIntercepted);

            _Settings = new HotKeySettings();
        }
示例#3
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new HotKeySettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(HotKeySettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as HotKeySettings;

            if (_Settings == null)
                _Settings = new HotKeySettings();
        }
示例#4
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

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

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(HotKeySettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite  = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return(Encoding.Default.GetString(mStream.ToArray()));
        }
示例#5
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new HotKeySettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(HotKeySettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as HotKeySettings;

            if (_Settings == null)
            {
                _Settings = new HotKeySettings();
            }
        }
示例#6
0
        private string GetDescription(HotKeySettings Settings)
        {
            if (Settings == null)
            {
                return("Send a hot key combination to application");
            }

            // Create string to store key combination and final output description
            string strKeyCombo        = "";
            string strFormattedOutput = "Send the hot key ({0}) to application";

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

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

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

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

            strKeyCombo += new ManagedWinapi.KeyboardKey(Settings.KeyCode).KeyName;             // Settings.KeyCode.ToString();

            // Return final formatted string
            return(String.Format(strFormattedOutput, strKeyCombo));
        }
示例#7
0
        private void SendShortcutKeys(HotKeySettings Settings)
        {
            if (Settings == null)
                return;

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

            // 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
            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();
        }
示例#8
0
        private string GetDescription(HotKeySettings Settings)
        {
            if (Settings == null)
                return "Send a hot key combination to application";

            // Create string to store key combination and final output description
            string strKeyCombo = "";
            string strFormattedOutput = "Send the hot key ({0}) to application";

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

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

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

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

            strKeyCombo += new ManagedWinapi.KeyboardKey(Settings.KeyCode).KeyName; // Settings.KeyCode.ToString();

            // Return final formatted string
            return String.Format(strFormattedOutput, strKeyCombo);
        }
示例#9
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

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

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(HotKeySettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return Encoding.Default.GetString(mStream.ToArray());
        }
示例#10
0
        private void SendShortcutKeys(HotKeySettings Settings)
        {
            if (Settings == null)
            {
                return;
            }

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

            // 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
            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();
            }
        }
示例#11
0
 public HotKeyUI(HotKeySettings KeySettings) : this()
 {
     Settings = KeySettings;
 }
示例#12
0
 public HotKeyUI(HotKeySettings KeySettings)
     : this()
 {
     Settings = KeySettings;
 }