Beispiel #1
0
        bool ParseNonPrintable(
            ParsePosition position,
            List <IInputAction> pressInputs,
            List <IInputAction> releaseInputs)
        {
            var separator = new char[1] {
                '}'
            };
            var strArray1 = position.ToString().Split(separator: (char[])null, options: StringSplitOptions.RemoveEmptyEntries);

            if (strArray1.Length != 0)
            {
                var strArray2 = strArray1[0].Split(separator: separator, options: StringSplitOptions.RemoveEmptyEntries);
                if (strArray2.Length != 0)
                {
                    var str = strArray2[0];
                    if (this.keyTranslator.IsNonPrintableName(name: str))
                    {
                        pressInputs.AddRange(collection: Input.CreateKeyInput(key: this.keyTranslator.GetVirtualKey(keyName: str), action: KeyAction.Press, duration: SendKeysDelay));
                        releaseInputs.AddRange(collection: Input.CreateKeyInput(key: this.keyTranslator.GetVirtualKey(keyName: str), action: KeyAction.Release, duration: SendKeysDelay));
                        position.Skip(count: str.Length);
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        bool ParseNumber(ParsePosition position, ref int number)
        {
            var position1 = (ParsePosition)position.Clone();
            var num       = 1;

            if (position1.CurrentChar == '+' || position1.CurrentChar == '-')
            {
                num = position1.CurrentChar == '+' ? 1 : -1;
                position1.MoveNext();
            }

            var digit = 0;

            if (!ParseDigit(position: position1, digit: out digit))
            {
                return(false);
            }
            number = digit;
            position.Skip(count: position1.CurrentIndex);
            while (ParseDigit(position: position, digit: out digit))
            {
                number = 10 * number + digit;
            }
            number *= num;
            return(true);
        }
Beispiel #3
0
        bool ParseDownUp(ParsePosition position, ref KeyAction keyAction)
        {
            if (position.GetRightString(length: 4) == "DOWN")
            {
                keyAction = KeyAction.Press;
                position.Skip(count: 4);
                return(true);
            }

            if (!(position.GetRightString(length: 2) == "UP"))
            {
                return(false);
            }
            keyAction = KeyAction.Release;
            position.Skip(count: 2);
            return(true);
        }
Beispiel #4
0
        bool ParseCurly(ParsePosition position, List <IInputAction> inputs)
        {
            if (position.CurrentChar != '{')
            {
                return(false);
            }
            var position1 = (ParsePosition)position.Clone();

            position1.MoveNext();
            var pressInputs   = new List <IInputAction>();
            var releaseInputs = new List <IInputAction>();

            if (!ParseSpecialChar(position: position1, pressInputs: pressInputs) && !ParseNonPrintable(position: position1, pressInputs: pressInputs, releaseInputs: releaseInputs) && !ParsePrintable(position: position1, pressInputs: pressInputs, releaseInputs: releaseInputs))
            {
                return(false);
            }
            var repetitionCount = 1;
            var keyAction       = KeyAction.PressAndRelease;

            if (ParseWhitespaces(position: position1) && !ParseCurlyPostfix(position: position1, repetitionCount: ref repetitionCount, keyAction: ref keyAction) || position1.CurrentChar != '}')
            {
                return(false);
            }
            position1.MoveNext();
            position.Skip(count: position1.CurrentIndex);
            for (var index = 0; index < repetitionCount; ++index)
            {
                switch (keyAction)
                {
                case KeyAction.Press:
                    inputs.AddRange(collection: pressInputs);
                    break;

                case KeyAction.Release:
                    inputs.AddRange(collection: releaseInputs);
                    break;

                case KeyAction.PressAndRelease:
                    inputs.AddRange(collection: pressInputs);
                    inputs.AddRange(collection: releaseInputs);
                    break;
                }
            }

            return(true);
        }
Beispiel #5
0
        bool ParseBlock(ParsePosition position, List <IInputAction> inputs)
        {
            if (position.CurrentChar != '(')
            {
                return(false);
            }
            var position1 = (ParsePosition)position.Clone();

            position1.MoveNext();
            var inputs1 = new List <IInputAction>();

            ParseInnerText(position: position1, inputs: inputs1);
            if (position1.CurrentChar != ')')
            {
                return(false);
            }
            position1.MoveNext();
            position.Skip(count: position1.CurrentIndex);
            inputs.AddRange(collection: inputs1);
            return(true);
        }
Beispiel #6
0
        bool ParseModifiers(ParsePosition position, List <IInputAction> inputs)
        {
            var position1       = (ParsePosition)position.Clone();
            var inputActionList = new List <IInputAction>();
            var releaseInputs   = new List <IInputAction>();

            if (!ParseModifier(position: position1, pressInputs: inputActionList, releaseInputs: releaseInputs))
            {
                return(false);
            }
            position.Skip(count: position1.CurrentIndex);
            do
            {
                ;
            } while (ParseModifier(position: position, pressInputs: inputActionList, releaseInputs: releaseInputs));

            if (!ParsePrintable(position: position, pressInputs: inputActionList, releaseInputs: releaseInputs) && !ParseCurly(position: position, inputs: inputActionList))
            {
                ParseBlock(position: position, inputs: inputActionList);
            }
            inputs.AddRange(collection: inputActionList);
            inputs.AddRange(collection: releaseInputs);
            return(true);
        }