Is SendKeys.SendWait() just a wrapper and these two code snippets are identical?
const int VK_ESCAPE = 0x1B;
keybd_event(VK_ESCAPE, 0, 0, 0);
keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
and
System.Windows.Forms.SendKeys.SendWait("{ESC}");
If not, is there any reason to use one over the other?
keybd_event() is a legacy API, you’re supposed to use SendInput() these days. SendKeys either uses a journaling hook or SendInput, depending on .config file setting. The journaling hook is legacy and still the default, SendInput works better on Vista and up, available since .NET 3. So, roughly, yes they are the same. The config setting is: