@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: TODO - a short description !!!!C# Signature: [DllImport("coredll.dll", SetLastError=true)] static extern uint SendInput(uint cInputs, /* [MarshalAs(UnmanagedType.LPArray)] */ KEYBOARDINPUT[] inputs, int cbSize); !!!!VB Signature: Declare Function SendInput Lib "coredll.dll" (TODO) As TODO !!!!User-Defined Types: None. !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: public class cTabControl { // The unused private fields below are required to match the native structure layout. #pragma warning disable 0169 public struct KEYBOARDINPUT { public uint type; public ushort wVk; ushort wScan; public uint dwFlags; uint time; uint dwExtraInfo; uint unused1; uint unused2; } #pragma warning restore 0169 public const uint INPUT_KEYBOARD = 1; public const uint KEYEVENTF_KEYUP = 2; public const ushort VK_TAB = 0x0009; public const ushort VK_SHIFT = 0x0010; public const ushort VK_CTRL = 0x0011; [DllImport("coredll.dll", SetLastError = true)] public static extern uint SendInput(uint cInputs, /* [MarshalAs(UnmanagedType.LPArray)] */ KEYBOARDINPUT[] inputs, int cbSize); #region SetTab /// <summary> /// Force the system to react, as if the Tab-key was pressed /// </summary> public static void SetTab() { KEYBOARDINPUT[] inputs; uint retVal; int error; inputs = new cTabControl.KEYBOARDINPUT[2]; inputs[0].type = inputs[1].type = cTabControl.INPUT_KEYBOARD; inputs[0].wVk = inputs[1].wVk = cTabControl.VK_TAB; inputs[1].dwFlags = cTabControl.KEYEVENTF_KEYUP; retVal = cTabControl.SendInput(2, inputs, 0x001C); if (retVal != 2) { error = Marshal.GetLastWin32Error(); throw new Exception(string.Format("SendInput() returned {0}.", error)); } } #endregion #region SetShiftTab /// <summary> /// Force the system to react, as if the Shift- and Tab-key was pressed /// </summary> public static void SetShiftTab() { KEYBOARDINPUT[] inputs; uint retVal; int error; inputs = new cTabControl.KEYBOARDINPUT[4]; inputs[0].type = inputs[1].type = inputs[2].type = inputs[3].type = cTabControl.INPUT_KEYBOARD; inputs[0].wVk = inputs[3].wVk = cTabControl.VK_SHIFT; inputs[1].wVk = inputs[2].wVk = cTabControl.VK_TAB; inputs[2].dwFlags = inputs[3].dwFlags = cTabControl.KEYEVENTF_KEYUP; retVal = cTabControl.SendInput(4, inputs, 0x001C); if (retVal != 4) { error = Marshal.GetLastWin32Error(); throw new Exception(string.Format("SendInput() returned {0}.", error)); } } #endregion #region SetCtrlTab /// <summary> /// Force the system to react, as if the Ctrl- and Tab-key was pressed /// </summary> public static void SetCtrlTab() { KEYBOARDINPUT[] inputs; uint retVal; int error; inputs = new cTabControl.KEYBOARDINPUT[4]; inputs[0].type = inputs[1].type = inputs[2].type = inputs[3].type = cTabControl.INPUT_KEYBOARD; inputs[0].wVk = inputs[3].wVk = cTabControl.VK_CTRL; inputs[1].wVk = inputs[2].wVk = cTabControl.VK_TAB; inputs[2].dwFlags = inputs[3].dwFlags = cTabControl.KEYEVENTF_KEYUP; retVal = cTabControl.SendInput(4, inputs, 0x001C); if (retVal != 4) { error = Marshal.GetLastWin32Error(); throw new Exception(string.Format("SendInput() returned {0}.", error)); } } #endregion #region SetCtrlShiftTab /// <summary> /// Force the system to react, as if the Ctrl-, Shift- and Tab-key was pressed /// </summary> public static void SetCtrlShiftTab() { KEYBOARDINPUT[] inputs; uint retVal; int error; inputs = new cTabControl.KEYBOARDINPUT[6]; inputs[0].type = inputs[1].type = inputs[2].type = inputs[3].type = inputs[4].type = inputs[5].type = cTabControl.INPUT_KEYBOARD; inputs[0].wVk = inputs[5].wVk = cTabControl.VK_CTRL; inputs[1].wVk = inputs[4].wVk = cTabControl.VK_SHIFT; inputs[2].wVk = inputs[3].wVk = cTabControl.VK_TAB; inputs[2].dwFlags = inputs[5].dwFlags = cTabControl.KEYEVENTF_KEYUP; retVal = cTabControl.SendInput(6, inputs, 0x001C); if (retVal != 6) { error = Marshal.GetLastWin32Error(); throw new Exception(string.Format("SendInput() returned {0}.", error)); } } #endregion } Documentation: SendInput@msdn on MSDN
Edit coredll.SendInput
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.