title: .NET sendkeys to calculator
body: <p>The sendkeys code below works well for Notepad but it doesn't work for Calculator. What is the problem? (It's another problem compared to what I sent here <a href="https://stackoverflow.com/questions/2604486/c-sendkeys-problem">Sendkeys problem from .NET program</a>)</p>
  
  <pre><code>[DllImport("user32.dll", CharSet = CharSet.Unicode)]
  public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
  [DllImport("User32")]
  public static extern bool SetForegroundWindow(IntPtr hWnd);
  private void button1_Click(object sender, EventArgs e)
  {
      IntPtr calculatorHandle = FindWindow("SciCalc", "Calculator");
      //IntPtr calculatorHandle = FindWindow("Notepad", "Untitled - Notepad");
      if (calculatorHandle == IntPtr.Zero)
      {
          MessageBox.Show("Calculator is not running.");
          return;
      }
      SetForegroundWindow(calculatorHandle);
      System.Threading.Thread.Sleep(1000);
      SendKeys.SendWait("111*11=");
      //SendKeys.SendWait("{ENTER}");
      //cnt++;
      SendKeys.Flush();
  }
  </code></pre>