Exemplo n.º 1
0
        private void SendLeftArrows(int length)
        {
            var inputs = new ConsoleControl.INPUT[length * 2];
            for (int i = 0; i < length; i++)
            {
                var down = new ConsoleControl.INPUT();
                down.Type = (UInt32)ConsoleControl.InputType.Keyboard;
                down.Data.Keyboard = new ConsoleControl.KeyboardInput();
                down.Data.Keyboard.Vk = (UInt16)ConsoleControl.VirtualKeyCode.Left;
                down.Data.Keyboard.Scan = 0;
                down.Data.Keyboard.Flags = 0;
                down.Data.Keyboard.Time = 0;
                down.Data.Keyboard.ExtraInfo = IntPtr.Zero;

                var up = new ConsoleControl.INPUT();
                up.Type = (UInt32)ConsoleControl.InputType.Keyboard;
                up.Data.Keyboard = new ConsoleControl.KeyboardInput();
                up.Data.Keyboard.Vk = (UInt16)ConsoleControl.VirtualKeyCode.Left;
                up.Data.Keyboard.Scan = 0;
                up.Data.Keyboard.Flags = (UInt32)ConsoleControl.KeyboardFlag.KeyUp;
                up.Data.Keyboard.Time = 0;
                up.Data.Keyboard.ExtraInfo = IntPtr.Zero;

                inputs[2 * i] = down;
                inputs[2 * i + 1] = up;
            }

            ConsoleControl.MimicKeyPress(inputs);
        }
Exemplo n.º 2
0
		private void SendLeftArrows(int length)
		{
			ConsoleControl.INPUT[] nPUTArray = new ConsoleControl.INPUT[length * 2];
			for (int i = 0; i < length; i++)
			{
				ConsoleControl.INPUT zero = new ConsoleControl.INPUT();
				zero.Type = 1;
				zero.Data.Keyboard = new ConsoleControl.KeyboardInput();
				zero.Data.Keyboard.Vk = 37;
				zero.Data.Keyboard.Scan = 0;
				zero.Data.Keyboard.Flags = 0;
				zero.Data.Keyboard.Time = 0;
				zero.Data.Keyboard.ExtraInfo = IntPtr.Zero;
				ConsoleControl.INPUT nPUT = new ConsoleControl.INPUT();
				nPUT.Type = 1;
				nPUT.Data.Keyboard = new ConsoleControl.KeyboardInput();
				nPUT.Data.Keyboard.Vk = 37;
				nPUT.Data.Keyboard.Scan = 0;
				nPUT.Data.Keyboard.Flags = 2;
				nPUT.Data.Keyboard.Time = 0;
				nPUT.Data.Keyboard.ExtraInfo = IntPtr.Zero;
				nPUTArray[2 * i] = zero;
				nPUTArray[2 * i + 1] = nPUT;
			}
			ConsoleControl.MimicKeyPress(nPUTArray);
		}