以下的sendkeys代码在记事本中运行良好,但在计算器中无法工作。问题出在哪里?(与我在这里发送的问题.NET程序的Sendkeys问题相比,这是另一个问题)
[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();
}