I use this code to do something in console :
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();
It is opening a program then uses SendKeys
. It is being run by a user who may click on another program, so it has problems because the focus may be set to another program.
So, how can I send keys specifically to my application?