以下の 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();
}