コード例 #1
0
 private static void processGroupings(Keyboard keyboard, KeyModifierPressedMgr keyModifierInfoMgr, string keySequence)
 {
     // paren groups
     foreach (string sequence in getGroupings(@"[+^%]+\(.+?\)", keySequence))
     {
         // process groupings
         if ("+^%".Contains(sequence[0]))
         {
             int    charsToRemove = keyModifierInfoMgr.push(sequence);
             string newSequence   = sequence.Substring(charsToRemove + 1, sequence.Length - charsToRemove - 2);
             processGroupings(keyboard, keyModifierInfoMgr, newSequence);
             keyModifierInfoMgr.pop();
         }
         else
         {
             processGroup(keyboard, keyModifierInfoMgr, sequence);
         }
     }
 }
コード例 #2
0
        private static void processGroup(Keyboard keyboard, KeyModifierPressedMgr keyModifierInfoMgr, string keySequence)
        {
            bool sendSingleModifierKey = false;

            List <string> a = getGroupings(@"[+^%]+|{\w+}|{[{}]}|{\w\s\d+}", keySequence);

            foreach (string sequence in a)
            {
                if ("+^%".Contains(sequence[0]))
                {
                    sendSingleModifierKey = true;
                    int charsToRemove = keyModifierInfoMgr.push(sequence);
                }
                else if (sequence[0] == '{')
                {
                    keyinfo matchedKyeInfo;
                    if (braceCodes.TryGetValue(sequence.ToUpper(), out matchedKyeInfo))
                    {
                        if (matchedKyeInfo.isSpecialKey)
                        {
                            keyboard.PressSpecialKey(matchedKyeInfo.specialKey);
                        }
                        else
                        {
                            keyboard.Enter(matchedKyeInfo.keys);
                        }
                    }
                    else                      // maybe {x n} - x n times
                    {
                        string[] words = sequence.Split(' ');
                        if (words.Length != 2)
                        {
                            throw new Exception("Invalid braced string: " + sequence);
                        }
                        for (int i = Int16.Parse(words[1]); i > 0; i--)
                        {
                            keyboard.Enter(words[0]);
                        }
                    }
                    if (sendSingleModifierKey)
                    {
                        sendSingleModifierKey = false;
                        keyModifierInfoMgr.pop();
                    }
                }
                else
                {
                    if (sendSingleModifierKey)
                    {
                        keyboard.Enter(sequence.Substring(0, 1));
                        sendSingleModifierKey = false;
                        keyModifierInfoMgr.pop();
                        if (sequence.Length > 1)
                        {
                            keyboard.Enter(sequence.Substring(1));
                        }
                    }
                    else
                    {
                        keyboard.Enter(sequence);
                    }
                }
            }
        }