I am trying to automate a process using a third party program in a C# console application. After my program starts the third party application (wxPirs.exe) I would like to wait (Thread.sleep
) for 5 seconds, and then I would like alt+f, down arrow, enter, enter to be entered in the third party program.
I can see this is easily accomplished using sendkeys in a forms application, but my application is console based and I would like for it to stay that way if at all possible. I have created this same program in python and there was a pynput
function that I could pip install
that was very easy to use. Is there anything like this in C# that I just haven't came across from my googling and reading documentation?
The code block this would go into is below:
static void unPirs()
{
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string unpackedPath = homePath + "\\XBLA_Unpacked\\";
string wxPirsPath = homePath + "\\wxPirs.exe";
var files = GetAllFiles(unpackedPath);
foreach (var file in files)
{
Console.WriteLine(file);
var process = Process.Start(wxPirsPath, "\"" + file + "\"");
Thread.Sleep(7500);
process.WaitForExit();
}