I'm having trouble with passing a keystroke into a windowless command line.
I start the process as per below:
public partial class BatchRun : Form
{
public void StartProcess(Process name)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = sMasterBATname;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
name.StartInfo = startInfo;
name.OutputDataReceived += new DataReceivedEventHandler(StandardOutputHandler);
name.StartInfo.RedirectStandardInput = true;
name.Start();
name.BeginOutputReadLine();
}
}
sMasterBATfile is a batch file which contains number of exe commands to execute. Each exe line is followed by a pause. This is necessary as I need to validate each line which is being redirected and sometimes exe is executed so quickly I have no time to check if it errored or not.
Output is redirected to partial class as per below.
public partial class BatchRun : Form
{
public void outLineValidation(string text)
{
if (text != null && !String.IsNullOrWhiteSpace(text))
{
if (text.Contains("Critical error") || text.Contains("Fatal error"))
{
Do something
}
else if (text.Contains("Complete run time"))
{
This is where I need to pass or
simulate a keystroke to be passed to the process that executes
exe files so that next exe can be executed.
}
}
}
}
I did some research but could not find any that was working for me. All I could find was that I need to bring window forward or pass message etc but not seems to be working.
Could someone help please and explain as if I was a 6 year old please.
Hope this makes sense.