/// <summary> /// Sends shortcut keys (key down and up) signals. /// </summary> /// <param name="kCode">The array of keys to send as a shortcut.</param> /// <param name="delay">The delay in milliseconds between the key down and up events.</param> public static void ShortcutKeys(Keys[] kCode, int delay = 0) { KeyPressStruct KeyPress = new KeyPressStruct(kCode, delay); Thread t = new Thread(() => KeyPressThread(KeyPress)); t.Start(); }
/// <summary> /// Sends shortcut keys (key down and up) signals. /// </summary> /// <param name="kCode">The array of keys to send as a shortcut.</param> /// <param name="Delay">The delay in milliseconds between the key down and up events.</param> /// <remarks></remarks> public static void ShortcutKeys(Keys[] kCode, int Delay /*= 0*/) { KeyPressStruct KeyPress = new KeyPressStruct(kCode, Delay); Thread t = new Thread(new ParameterizedThreadStart(KeyPressThread)); t.Start(KeyPress); }
/// <summary> /// Sends a key press signal (key down and up). /// </summary> /// <param name="kCode">The virtual key code to send.</param> /// <param name="delay">The delay to set between the key down and up commands.</param> public static void KeyPress(Keys kCode, int delay = 0) { Keys[] SendKeys = new[] { kCode }; KeyPressStruct KeyPress = new KeyPressStruct(SendKeys, delay); Thread t = new Thread(() => KeyPressThread(KeyPress)); t.Start(); }
/// <summary> /// Sends a key press signal (key down and up). /// </summary> /// <param name="kCode">The virtual key code to send.</param> /// <param name="Delay">The delay to set between the key down and up commands.</param> /// <remarks></remarks> public static void KeyPress(Keys kCode, int Delay /*= 0*/) { Keys[] SendKeys = new Keys[] { kCode }; KeyPressStruct KeyPress = new KeyPressStruct(SendKeys, Delay); Thread t = new Thread(new ParameterizedThreadStart(KeyPressThread)); t.Start(KeyPress); }
public static void KeyPressThread(object obj) { KeyPressStruct KeysP = (KeyPressStruct)obj; foreach (Keys k in KeysP.Keys) { KeyDown(k); } if (KeysP.Delay > 0) { Thread.Sleep(KeysP.Delay); } foreach (Keys k in KeysP.Keys) { KeyUp(k); } }
private static void KeyPressThread(KeyPressStruct keysP) { foreach (Keys k in keysP.Keys) { KeyDown(k); } if (keysP.Delay > 0) { Thread.Sleep(keysP.Delay); } foreach (Keys k in keysP.Keys) { KeyUp(k); } }