public static void SendSpace(IntPtr hwnd, VirtualInputMethod inputMethod) { switch (inputMethod) { case VirtualInputMethod.SendMessage: SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, IntPtr.Zero); SendMessage(hwnd, WM_KEYUP, VK_SPACE, IntPtr.Zero); break; case VirtualInputMethod.PostMessage: PostMessage(hwnd, WM_KEYDOWN, (IntPtr)VK_SPACE, IntPtr.Zero); PostMessage(hwnd, WM_KEYUP, (IntPtr)VK_SPACE, IntPtr.Zero); break; case VirtualInputMethod.SendWait: System.Windows.Forms.SendKeys.SendWait(" "); break; } }
public static void SendCharacter(IntPtr hwnd, VirtualInputMethod inputMethod, char c) { switch (inputMethod) { case VirtualInputMethod.SendMessage: SendMessage(hwnd, WM_CHAR, c, IntPtr.Zero); break; case VirtualInputMethod.PostMessage: PostMessage(hwnd, WM_CHAR, (IntPtr)c, IntPtr.Zero); break; default: if (Utils.IsSpecialCharacter(c)) { if (inputMethod == VirtualInputMethod.SendWait) { System.Windows.Forms.SendKeys.SendWait("{" + c.ToString() + "}"); } else { System.Windows.Forms.SendKeys.Send("{" + c.ToString() + "}"); } } else { if (inputMethod == VirtualInputMethod.SendWait) { System.Windows.Forms.SendKeys.SendWait(c.ToString()); } else { System.Windows.Forms.SendKeys.Send(c.ToString()); } } break; } }