2

I am using the method GetForegroundWindow() to get the window a user is using. But if the window is Windows Store App/UWP app (example the calculator) I get the window with a title (Reiknivél in Icelandic), but the process is ApplicationFrameHost. The problem is that I need the underlying process. I am now working on a method that takes that title and returns the process, but I have no idea how to connect the ApplicationFrameHost process to the real process.

I have been trying to get the hwnd for the window shown in the screenshot (link below). I am trying to get at it from one of the threads I can get from the calculator process. When I iterate all the windows from that thread using GetWindowHandlesForThread() I can get the other two and their titles, but the hwnd for the Windows.UI.Core window does not show up. And I know it's there because if I use Spy++ I can see it.

Any Ideas on how to get at it using C#? I have tried EnumWindows, EnumChildWindows, EnumThreadWindows and even GetGUIThreadInfoand all I have gotten from the ones that worked were the other two windows, never the CoreWindow that I need. Any ideas of how I could achieve this?

enter image description here

Chris Johnsson
  • 468
  • 4
  • 13
  • Have you tried EnumWindows - does that give them same behaviour? – Ben Jackson Sep 30 '16 at 13:51
  • 1
    I think I cannot use EnumChildWindows on threads because it needs hwnd. I have tried EnumChildWindows on the ApplicationFrameHost process, and gotten all the window handles it hosts, but I dont know how i can use that to connect it to the real calculator process. If try to get process from that handle it points back to application framehost, not the real calculator process. – Chris Johnsson Sep 30 '16 at 16:33
  • Btw I can get the process for calculator, and there i can see a MainWindowHandle, and using that i can get the title I wanna use to connect the two, but the problem is that this handle is only available if the actual window is minimized, if the window is in the Foreground, the handle becomes 0. – Chris Johnsson Sep 30 '16 at 16:48

0 Answers0