internal static void SendKeyboardInputVK( byte vk, bool press )
{
UnsafeNativeMethods.INPUT ki = new UnsafeNativeMethods.INPUT();
ki.type = UnsafeNativeMethods.INPUT_KEYBOARD;
ki.union.keyboardInput.wVk = vk;
ki.union.keyboardInput.wScan = 0;
ki.union.keyboardInput.dwFlags = press ? 0 : UnsafeNativeMethods.KEYEVENTF_KEYUP;
ki.union.keyboardInput.time = 0;
ki.union.keyboardInput.dwExtraInfo = new IntPtr( 0 );
if( UnsafeNativeMethods.SendInput( 1, ref ki, Marshal.SizeOf(ki) ) == 0 )
throw new Win32Exception(Marshal.GetLastWin32Error());
}