예제 #1
0
        public override void Do()
        {
            string previous_clipboard = Clipboard.GetText();

            Clipboard.SetText(topaste);
            System.Threading.Thread.Sleep(50);
            KeySender.KeyPress(KeyConverter.Name2Key(KeyConverter.WinFormKey2Name(Keys.LControlKey)));
            KeySender.KeyStroke(KeyConverter.Name2Key(KeyConverter.WinFormKey2Name(Keys.V)));
            KeySender.KeyRelease(KeyConverter.Name2Key(KeyConverter.WinFormKey2Name(Keys.LControlKey)));
            System.Threading.Thread.Sleep(50);
            try
            {
                Clipboard.SetText(previous_clipboard);
            }
            catch
            {
                try
                {
                    Clipboard.SetText("");
                }
                catch { }
            }
        }
예제 #2
0
        private void OnUserKeyboardPress(object sender, KeyEventArgs e)
        {
            idletime = 0;
            if ((int)e.KeyCode == ActivateKey)
            {
                MacroActivate = true;
                if (testing)
                {
                    string name = WindowManager.GetActiveWindowTitle();
                    string exe  = WindowManager.GetActiveWindowExename();
                    TopMostMessageBox.Show(
                        String.Format(Translations.Get("window_info_result_text"), name, exe),
                        Translations.Get("window_info_result_title"));
                    testing = false;
                }
            }

            switch (e.KeyCode)
            {
            case System.Windows.Forms.Keys.LShiftKey:
            case System.Windows.Forms.Keys.RShiftKey:
            case System.Windows.Forms.Keys.Shift:
            case System.Windows.Forms.Keys.ShiftKey:
                shift = true;
                break;
            }

            while (PressedKeys.Contains(e.KeyCode))
            {
                PressedKeys.Remove(e.KeyCode);
            }

            PressedKeys.Add(e.KeyCode);

            if (KeyHelper.Form_Visible)
            {
                KeyHelper.BoxContent += KeyConverter.WinFormKey2Name(e.KeyCode) + "\n";
                e.Handled             = true;
            }
            else if (ProceedRewriteMacros(e.KeyCode))
            {
                e.Handled = true;
            }

            //Handle french ^ and ¨ key modifiers: êâôëü
            if ((int)e.KeyCode == 221 && !circumflex)
            {
                circumflex = true;
                e.Handled  = true;
                if (shift)
                {
                    diaeresis = true;
                }
            }
            else if (circumflex && !circumflexOn)
            {
                circumflexOn = true;
                switch (e.KeyCode)
                {
                case (System.Windows.Forms.Keys) 221:
                    circumflex = false;
                    diaeresis  = false;
                    if (diaeresis)
                    {
                        KeySender.KeyPress(KeyConverter.Name2Key("Shift"));
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                        KeySender.KeyRelease(KeyConverter.Name2Key("Shift"));
                    }
                    else
                    {
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                    }
                    break;

                case System.Windows.Forms.Keys.A:
                case System.Windows.Forms.Keys.E:
                case System.Windows.Forms.Keys.I:
                case System.Windows.Forms.Keys.O:
                case System.Windows.Forms.Keys.U:
                case System.Windows.Forms.Keys.Y:
                    if (diaeresis)
                    {
                        KeySender.KeyPress(KeyConverter.Name2Key("Shift"));
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                        KeySender.KeyRelease(KeyConverter.Name2Key("Shift"));
                    }
                    else
                    {
                        KeySender.KeyStroke(KeySender.VkKeyScan('^'));
                    }
                    circumflex = false;
                    diaeresis  = false;
                    break;

                default:
                    circumflex = false;
                    diaeresis  = false;
                    break;
                }
                circumflexOn = false;
            }
        }