我使用此代码在控制台中执行某些操作:
System.Diagnostics.Process Process = new System.Diagnostics.Process();
Process.StartInfo.FileName = @"MyDir\MyApp.exe";
Process.StartInfo.WorkingDirectory = @"MyDir\MyApp.exe";
Process.Start();
System.Threading.Thread.Sleep(10000);
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
Process.Kill();
它正在打开一个程序然后使用SendKeys
. 它由可能单击另一个程序的用户运行,因此它有问题,因为焦点可能设置到另一个程序。
那么,如何将密钥专门发送到我的应用程序?