title: SendInput() not equal to pressing key manually on keyboard in C++?
body: <p>I wanted to write a c++ code to emulate pressing a keyboard key "A":</p>
  
  <pre><code>// Set up a generic keyboard event.
  ip.type = INPUT_KEYBOARD;
  ip.ki.wScan = 0; // hardware scan code for key
  ip.ki.time = 0;
  ip.ki.dwExtraInfo = 0;
  
  // Press the "..." key
  ip.ki.wVk = code; // virtual-key code for the "a" key
  ip.ki.dwFlags = 0; // 0 for key press
  SendInput(1, &amp;ip, sizeof(INPUT));
  
  // Release the "..." key
  ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
  SendInput(1, &amp;ip, sizeof(INPUT));
  </code></pre>
  
  <p>It works fine when I launch other program and wait to my program execute, the "A" is clicked and first program react to it. But I found that in the other application my action was somehow prevented (I can manually press "A" on keyboard, but using my program do not cause any action).</p>
  
  <p><strong>So, what I can do to make pressing "A" from program more identical to manually pressed "A"</strong> (so the second program won't recognize that it was called from program)?</p>
  
  <p>I do not have source code of second program and do not know how it recognize that "A" wasn't pressed manually.</p>
  
  <p>I'm sure that the window I want to react to my code is foreground, receive and block my key (so it can decide that event doesn't come from user but from program).</p>