Beispiel #1
0
 /// <summary>
 /// 按下键盘键
 /// </summary>
 /// <param name="vKey">虚拟键码</param>
 public static void SendKeyDown(short vKey)
 {
     NativeMethods.INPUT[] input = new NativeMethods.INPUT[1];
     input[0].type    = NativeMethods.INPUT_KEYBOARD;
     input[0].ki.wVk  = vKey;
     input[0].ki.time = UnsafeNativeMethods.GetTickCount();
     UnsafeNativeMethods.SendInput((uint)input.Length, input, Marshal.SizeOf(input[0]));
 }