[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
None.
None.
This function is usefull to simulate Key presses (for input use the virtual keycodes from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp (see also VkKeyScan):
void PressKey( byte keyCode )
{
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
keybd_event( keyCode, 0x45, KEYEVENTF_EXTENDEDKEY, 0 );
keybd_event( keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
}
Please add some!
<b>PROBLEM</b> : How do i use combination of shift and tab keys at the same time ?
<b>Answer</b>
posted by dokks http://www.ravensmyst.com
define the shift key as a const
public const byte VK_LSHIFT= 0xA0; // left shift key
public const byte VK_TAB = 0x09;
public const int KEYEVENTF_EXTENDEDKEY = 0x01;
public const int KEYEVENTF_KEYUP = 0x02;
//press the alt key
keybd_event(VK_LSHIFT, 0x45, 0, 0);
//press the tab key
keybd_event(VK_TAB, 0x45, 0, 0);
//release the tab key
keybd_event(VK_TAB, 0x45, KEYEVENTF_KEYUP, 0);
//release the alt key
keybd_event(VK_LSHIFT, 0x45, KEYEVENTF_KEYUP, 0);