I want to create a windows form type application in C# that opens an installation wizard .exe and automatically presses the Next> Next> Finish buttons (To give an example)
I already have the test button created and I have the code to open the .exe using: System.Diagnostics.Process.Start(@"E:\ ..... .exe);
I also created a function for the application to go to the front and I am passing the "Enter" key several times so that it hits the "next" button of the application but it does not work, if someone could help me I would appreciate it, here I leave my code so far.
//THIS IS THE CODE OF THE BUTTON
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(@"E:\programas pcs\winrar-x64-411es.exe");
Thread.Sleep(1000);
Funciones.ActivateApp("winrar-x64-411es.exe");
Thread.Sleep(2000);
SendKeys.SendWait("{ENTER}");
Thread.Sleep(2000);
SendKeys.Send("{ENTER}");
Thread.Sleep(2000);
}
//FUNCION ACTIVATEAPP
public static void ActivateApp(string processName)
{
Process[] p = Process.GetProcessesByName(processName);
if (p.Count() > 0)
SetForegroundWindow(p[0].MainWindowHandle);
}
try using these parameters and methods