/// <summary> /// Returns information about a simulated keyboard event. /// </summary> /// <param name="wvk">A virtual-key code. The code must be a value in the range 1 to 254. If the <paramref name="dwFlags"/> member specifies <see cref="KeyBoardInputDwFlag.KEYEVENTF_UNICODE"/>, <paramref name="wvk"/> must be 0.</param> /// <param name="dwFlags">A hardware scan code for the key. If <paramref name="dwFlags"/> specifies <see cref="KeyBoardInputDwFlag.KEYEVENTF_UNICODE"/>, <paramref name="wScan"/> specifies a Unicode character which is to be sent to the foreground application.</param> /// <param name="wScan">Specifies various aspects of a keystroke.</param> /// <param name="time">The time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.</param> /// <param name="dwExtraInfo">An additional value associated with the keystroke. Use the <see cref="User32.GetMessageExtraInfo"/> function to obtain this information.</param> /// <returns></returns> public static UInt32 SendKeyboardInput(KeyCode wvk, KeyBoardInputDwFlag dwFlags, UInt16 wScan = 0, UInt32 time = 0, IntPtr dwExtraInfo = default(IntPtr)) => User32.SendInput( pInput: InputFactory.CreateKeyboardInput( wvk: wvk, dwFlags: dwFlags, wScan: wScan, time: time, dwExtraInfo: dwExtraInfo));
/// <summary> /// /// </summary> /// <param name="wvk">A virtual-key code. The code must be a value in the range 1 to 254. If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.</param> /// <param name="dwFlags">A hardware scan code for the key. If dwFlags specifies KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be sent to the foreground application.</param> /// <param name="wScan">Specifies various aspects of a keystroke.</param> /// <param name="time">The time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.</param> /// <param name="dwExtraInfo">An additional value associated with the keystroke. Use the GetMessageExtraInfo function to obtain this information.</param> /// <returns></returns> public static Input CreateKeyboardInput(KeyCode wvk, KeyBoardInputDwFlag dwFlags, UInt16 wScan = 0, UInt32 time = 0, IntPtr dwExtraInfo = default(IntPtr)) { if (dwExtraInfo == default(IntPtr)) { dwExtraInfo = User32.GetMessageExtraInfo(); } return(new Input() { type = InputType.INPUT_KEYBOARD, u = new InputUnion() { ki = new KeyBoardInput() { wvk = wvk, dwFlags = dwFlags, wScan = wScan, time = time, dwExtraInfo = dwExtraInfo } } }); }