Пример #1
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == Constants.WIN_MSG_HOTKEY_DOWN && IsEnabled)
            {
                //Credit to http://www.fluxbytes.com/csharp/how-to-register-a-global-hotkey-for-your-application-in-c/

                Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                Constants.KeyModifier modifier = (Constants.KeyModifier)((int)m.LParam & 0xFFFF);
                int id = m.WParam.ToInt32();

                HotKey local       = new HotKey(id, (int)modifier, key);
                string pathToTheme = HotKeys[local].GetNextTheme();

                try
                {
                    execCMDThemeChange(pathToTheme);
                }
                catch (Win32Exception e)
                {
                    FileLogger.Log($"File to theme could not be accessed.\nTheme: {pathToTheme}\n" + e.Message, LogOptions.DISPLAY_ERROR);
                }
            }
        }
        private void PickHotKeyDialog_KeyDown(object sender, KeyEventArgs e)
        {
            lblPickKey.Text    = "";
            Key                = (Keys)e.KeyValue;
            lblKeyPressed.Text = getKeyString(Key);

            if ((ModifierKeys & Keys.Shift) == Keys.Shift)
            {
                lblKeyMod.Text = @"SHIFT";
                KeyMod         = Constants.KeyModifier.SHIFT;
            }
            else if ((ModifierKeys & Keys.Alt) == Keys.Alt)
            {
                lblKeyMod.Text = @"ALT";
                KeyMod         = Constants.KeyModifier.ALT;
            }
            else if ((ModifierKeys & Keys.Control) == Keys.Control)
            {
                lblKeyMod.Text = @"CONTROL";
                KeyMod         = Constants.KeyModifier.CONTROL;
            }
            else
            {
                lblKeyMod.Text = @"NONE";
                KeyMod         = Constants.KeyModifier.NONE;
            }

            KeyPressed = true;
        }
Пример #3
0
        private void btnPickHotKey_Click(object sender, EventArgs e)
        {
            PickHotKeyDialog phkd = new PickHotKeyDialog();

            HelperFunc.CreateFormStartPosition(ref phkd, this);

            DialogResult result = phkd.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            HKKey    = phkd.Key;
            HKKeyMod = phkd.KeyMod;

            lblKeyOK.Text      = @"Finished";
            lblKeyOK.ForeColor = Color.Green;
        }