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 + ")"; }
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); }
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()); }
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]); }
protected override void SetInputs(char character) { Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(character), InputSimulator.KeyWrapper(character, true) }; }
protected override void SetInputs(ScanCode scanCode) { Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode), InputSimulator.KeyWrapper(scanCode, true) }; }
public KeyTap(ScanCode scanCode) { Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(scanCode), InputSimulator.KeyWrapper(scanCode, true) }; toString = "KeyTap(" + scanCode.ToString() + ")"; }
public KeyTap(char key) { Inputs = new InputWrapper[] { InputSimulator.KeyWrapper(key), InputSimulator.KeyWrapper(key, true) }; toString = "KeyTap(" + key + ")"; }