Exemplo n.º 1
0
        public WriteText(string text)
        {
            List <InputWrapper> inputs = new List <InputWrapper>();

            for (int i = 0; i < text.Length; i++)
            {
                var sci = InputSimulator.AsciiToScanCode(text[i]);

                if (sci.IsShifted)
                {
                    inputs.Add(InputSimulator.KeyWrapper(new KeyboardInputData {
                        Scan = ScanCode.lshift, Flags = KeyboardFlags.ScanCode
                    }));
                }
                inputs.Add(InputSimulator.KeyWrapper(new KeyboardInputData {
                    Key = sci.VkKey, Scan = sci.ScanCode
                }));
                inputs.Add(InputSimulator.KeyWrapper(new KeyboardInputData {
                    Key = sci.VkKey, Scan = sci.ScanCode, Flags = KeyboardFlags.KeyUp
                }));
                if (sci.IsShifted)
                {
                    inputs.Add(InputSimulator.KeyWrapper(new KeyboardInputData {
                        Scan = ScanCode.lshift, Flags = KeyboardFlags.ScanCode | KeyboardFlags.KeyUp
                    }));
                }
            }

            this.inputs = inputs.ToArray();
            toString    = "WriteText(" + text + ")";
        }
Exemplo n.º 2
0
        public void ReleaseKey(IList <ScanCode> scanCodes)
        {
            var inputData = new InputWrapper[scanCodes.Count];

            for (int i = 0; i < inputData.Length; i++)
            {
                Device.KeyRepeater.KeyUp(scanCodes[i]);
                inputData[i] = InputSimulator.KeyWrapper(scanCodes[i], true, ((int)scanCodes[i] & 0x100) == 0x100);
            }

            Interop.SendInput((uint)inputData.Length, inputData);
        }
Exemplo n.º 3
0
        public void PressAndReleaseKey(IList <ScanCode> scanCodes)
        {
            var inputData = new List <InputWrapper>();

            for (int i = 0; i < scanCodes.Count; i++)
            {
                var extended = ((int)scanCodes[i] & 0x100) == 0x100;
                inputData.Add(InputSimulator.KeyWrapper(scanCodes[i], false, extended));
                inputData.Add(InputSimulator.KeyWrapper(scanCodes[i], true, extended));
            }

            Interop.SendInput((uint)inputData.Count, inputData.ToArray());
        }
Exemplo n.º 4
0
        public void PressKey(IList <ScanCode> scanCodes)
        {
            var inputData = new InputWrapper[scanCodes.Count];

            for (int i = 0; i < inputData.Length; i++)
            {
                inputData[i] = InputSimulator.KeyWrapper(scanCodes[i], false, ((int)scanCodes[i] & 0x100) == 0x100);
            }

            Interop.SendInput((uint)inputData.Length, inputData);

            Device.KeyRepeater.KeyDown(scanCodes[scanCodes.Count - 1]);
        }
Exemplo n.º 5
0
 protected override void SetInputs(char character)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(character), InputSimulator.KeyWrapper(character, true) };
 }
Exemplo n.º 6
0
 protected override void SetInputs(ScanCode scanCode)
 {
     Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode), InputSimulator.KeyWrapper(scanCode, true) };
 }
Exemplo n.º 7
0
 public KeyTap(ScanCode scanCode)
 {
     Inputs   = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode), InputSimulator.KeyWrapper(scanCode, true) };
     toString = "KeyTap(" + scanCode.ToString() + ")";
 }
Exemplo n.º 8
0
 public KeyTap(char key)
 {
     Inputs   = new InputWrapper[] { InputSimulator.KeyWrapper(key), InputSimulator.KeyWrapper(key, true) };
     toString = "KeyTap(" + key + ")";
 }