0

So I'm trying to get the Window handle for a Microsoft edge instance that I'm spawning.

Seem to be able to find pretty much everything but the Edge instance and I'm wondering if Windows Apps behave differently when using this approach.

For example I visit Google.com with the Edge instance I've created so the title of the window is "Google" but when I inspect MainWindowTitle its never "Google" or anything related to the Edge instance.

What am I doing wrong here and if this method is flawed what are my options for getting a handle for the instance I've spawned?

I've tried doing it by process ID but it spawns off other processes that you can't seem to get by the parent process ID.

        p.StartInfo.FileName = @"explorer.exe";
        p.StartInfo.Arguments = @" shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge";
        started = p.Start();

        foreach (Process pList in Process.GetProcesses())
        {
            if(pList.MainWindowTitle.Length>0)
            {
                if (pList.MainWindowTitle.Contains("Google"))
                {
                    hWnd = pList.MainWindowHandle;
                }
            }
        }
Mr J
  • 2,655
  • 4
  • 37
  • 58
  • Id imagine you would need to look for edge processes, and then run specific commands to scrape out if its looking at google – BugFinder Jun 13 '16 at 12:46
  • `p.MainWindowHandle` doesn't have the handle? – theB Jun 13 '16 at 12:50
  • 3
    Edge is a Modern UI app, MainWindowHandle is not its window. Easy to see when you use the Spy++ utility. You'd need to find the ApplicationFrameTitleBarWindow child window back with EnumChildWindows, rough guidance [is here](http://stackoverflow.com/a/32513438/17034). The odds that this will still work correctly 5 years from now are not very good, use UI Automation to make it last. – Hans Passant Jun 13 '16 at 12:56

0 Answers0