title: Sending keystrokes to an application, SendKeys.Send() vs SendMessage()
body: <p>I have created a simple bot to automate some things in a game. I'm currently sendings commands to the game by bringing the game window to the foreground and sending keys using <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys%28v=vs.110%29.aspx" rel="noreferrer">SendKeys</a>, like this:</p>
  
  <pre><code>SendKeys.Send("{ENTER}")
  </code></pre>
  
  <p>What I would like to know is, from a detectability point of view, if it's easier for anti cheat engines and such to detect something like this (using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx" rel="noreferrer">SendMessage</a>):</p>
  
  <pre><code>public static void SendKeystroke(ushort k)
  {
      const uint WM_KEYDOWN = 0x100;
      const uint WM_SYSCOMMAND = 0x018;
      const uint SC_CLOSE = 0x053;
  
      IntPtr WindowToFind = FindWindow(null, "Untitled1 - Notepad++");
  
      IntPtr result3 = SendMessage(WindowToFind, WM_KEYDOWN, 
                                      ((IntPtr)k), (IntPtr)0);
  }
  
  SendKeystroke(Keys.Enter);
  </code></pre>
  
  <p>In the end, the game would receive a keydown event for the enter key nontheless, right?</p>