Example #1
0
        /// <summary>
        /// Send text to keyboard parsing text using .Net SendKeys.SendWait(...) method formatting.
        /// See: http://msdn2.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(VS.90).aspx
        /// </summary>
        /// <param name="text"></param>
        public void SendWait(string text)
        {
            ISendKeysParser parser = parserFactory.Create(text);

            foreach (ISendKeysParserGroup group in parser.Groups)
            {
                List <VirtualKeyCodes> modifierKeys = new List <VirtualKeyCodes>();

                string modifierCharacters = group.ModifierCharacters;
                foreach (char modifierCharacter in modifierCharacters)
                {
                    modifierKeys.Add(modifierKeyMap[modifierCharacter]);
                }

                PressKeysDown(modifierKeys.ToArray());

                VirtualKeyCodes escapedKey = group.EscapedKey;
                if (escapedKey != VirtualKeyCodes.None)
                {
                    PressAndRelease(escapedKey);
                }

                TypeUnformated(group.Body);

                modifierKeys.Reverse();
                ReleaseKeys(modifierKeys.ToArray());
            }
        }
Example #2
0
        /// <summary>
        /// Send text to keyboard parsing text using .Net SendKeys.SendWait(...) method formatting.
        /// See: http://msdn2.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait(VS.90).aspx
        /// </summary>
        /// <param name="text"></param>
        public void SendWait(string text)
        {
            ISendKeysParser parser = parserFactory.Create(text);

            foreach (ISendKeysParserGroup group in parser.Groups)
            {
                string modifierCharacters = group.ModifierCharacters;
                //TODO examine other uses of modifierKeys, can I use .ToArray instead and avoid the copies?
                var modifierKeys = modifierCharacters.Select(modChar => modifierKeyMap[modChar]).ToList();

                PressKeysDown(modifierKeys.ToArray());

                VirtualKeyCodes escapedKey = group.EscapedKey;
                if (escapedKey != VirtualKeyCodes.None)
                {
                    PressAndRelease(escapedKey);
                }

                TypeUnformated(group.Body);

                modifierKeys.Reverse();
                ReleaseKeys(modifierKeys.ToArray());
            }
        }