I have a piece of code in Unity which opens another EXE file using the process.Start().
After the process starts, I am getting the main window handle and trying to set the position and window size.
This is my code:
Process process = new Process();
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.StartInfo.FileName = "someApp.exe"
process.StartInfo.Arguments = "SomeArgs";
process.Start();
UpdateProcessWindow(process);
private void UpdateProcessWindow(Process process)
{
// Waits for 10 seconds
if (process.WaitForInputIdle(10 * 1000))
{
IntPtr hwnd = process.MainWindowHandle;
SetForegroundWindow(hwnd);
MoveWindow(hwnd, 500, 500, 1000, 500, true);
}
}
Before this process is closed, if I manually modify the size of this window, then every time I start the process, the size is set to the manually edited size/position. I want to start the process with a 1000 width and 500 height always.
What am I missing here?