Vivek Kumar

Vivek Kumar

  • 1.7k
  • 3
  • 309

Unable to fetch MainWindowTilte for a launched process

Feb 13 2024 12:09 PM

Hi ,
I have windows 11. I have a console application using which i am trying to lauch a calculator application. For this lauched calculator application , i wanted to know the MainWindowTitle. But it returns an empty string. Please find below the code snippet:

 ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Windows\System32\calc.exe");

                    //startInfo.RedirectStandardOutput = true;
                    startInfo.UseShellExecute = false;
                    startInfo.WindowStyle = ProcessWindowStyle.Normal;

                    var myProcess = Process.Start(startInfo);
                  
                    myProcess.WaitForInputIdle();

                    Console.Write("Main window Title : " + myProcess.MainWindowTitle.ToString());

                    myProcess.CloseMainWindow().

In the above code, myProcess.MainWindowTitle returns a empty string . But ideally it should not as calculator has a graphic UI.
Thanks 


Answers (1)