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
Sam HobbsPosted Feb 13, 2024, 10:13 PM
When I use Spy++ and find the Calculator window then the window class is
Windows.UI.Core.CoreWindow, as in:CoreWindow Class (Windows.UI.Core) - Windows UWP applications | Microsoft Learn https://learn.microsoft.com/en-us/uwp/api/windows.ui.core.corewindow?view=winrt-22621
Also, in the Windows tab of Spy++ for the window, when I click on the parent window's handle then go to the
Processtab for it then the process is the mysteriousApplicationFrameHost.Apparently the Calculator application is a UWP application and Microsoft has made modern applications messy. I assume that the Calculator application is just an example and it is actually some other application that you need to do this with. You might be successful by doing something more complicated, such as finding windows with the class
Windows.UI.Core.CoreWindow.