@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The SendInput API !!!!C# Signature: [DllImport("user32.dll")] static extern uint SendInput(uint nInputs, INPUT [] pInputs, int cbSize); !!!!VB Signature: Declare Function SendInput Lib "user32.dll" (nInputs As Integer, pInputs() As _ INPUT, cbSize As Integer) !!!!User-Defined Types: [INPUT], and [VK] is used in the sample code. !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: class Test { void Test() { INPUT structInput; structInput.type = Win32Consts.INPUT_KEYBOARD; // Key down shift, ctrl, and/or alt structInput.ki.wScan = 0; structInput.ki.time = 0; structInput.ki.dwFlags = 0; structInput.ki.dwExtraInfo = Win32.GetMessageExtraInfo(); if (Shift) { structInput.ki.wVk = (ushort)VK.SHIFT; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Ctrl) { structInput.ki.wVk = (ushort)VK.CONTROL; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Alt) { structInput.ki.wVk = (ushort)VK.MENU; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Win) { structInput.ki.wVk = (ushort)VK.LWIN; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } // Key down the actual key-code structInput.ki.wVk = vk; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); // Key up the actual key-code structInput.ki.dwFlags = Win32Consts.KEYEVENTF_KEYUP; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); // Key up shift, ctrl, and/or alt if (Shift) { structInput.ki.wVk = (ushort)VK.SHIFT; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Ctrl) { structInput.ki.wVk = (ushort)VK.CONTROL; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Alt) { structInput.ki.wVk = (ushort)VK.MENU; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } if (Win) { structInput.ki.wVk = (ushort)VK.LWIN; intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT)); } } } !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: SendInput@msdn on MSDN
Edit user32.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.