简体   繁体   English

如何从C#查找Windows Universal应用程序窗口

[英]How to find Windows Universal app windows from C#

I want to write my own program that lets me select one Window of ALL open windows and set the state of this window to TOP, so that this selected window will always show on top! 我想编写自己的程序,让我从所有打开的窗口中选择一个窗口,并将该窗口的状态设置为TOP,这样该选定窗口将始终显示在顶部!

The problem... since Windows 8 there are APPs and actually the process comes up in the process explorer but my selection of my tool doesn't list it. 问题...由于Windows 8中有APP,实际上该过程出现在过程浏览器中,但是我选择的工具没有列出它。 (Its like there is no app) (就像没有应用一样)

My source looks like: 我的来源看起来像:

private void refreshWindowList(object sender, EventArgs e)
{
    windowList.Items.Clear();

    foreach (Process p in Process.GetProcesses().Where(pp => pp.MainWindowHandle != IntPtr.Zero && pp.ProcessName != "explorer"))
    {
        windowList.Items.Add(p.ProcessName);
    }
}

This function is called when I open my combobox and actually refresh the Items every time when I view the list. 当我打开组合框并在每次查看列表时实际上刷新项目时,将调用此函数。

I find normal programs, but is there a way to find Win 8/10 apps ? 我可以找到普通程序,但是有找到Win 8/10应用程序的方法吗?

EDIT to clarify : Normal processes like notepad can be found. 编辑以澄清 :可以找到类似记事本的常规过程。 But Windows Universal apps like eg netflix can't. 但是Windows通用应用程序(例如netflix)不能。 At least I don't know how to find them. 至少我不知道如何找到它们。

Some applications, eg Netflix, are written using HTML and JavaScript. 某些应用程序(例如Netflix)是使用HTML和JavaScript编写的。 These apps are hosted by WWAHost : 这些应用程序由WWAHost托管:

[...] Microsoft explains WWAHost as “an Internet Explorer-based rendering platform.” [...]微软将WWAHost解释为“基于Internet Explorer的呈现平台。”

You can check if this is the case for an app by right clicking it in the Task Manager and choosing Go to details : 您可以在“任务管理器”中右键单击该应用,然后选择“ 转到详细信息”,以检查该应用是否属于这种情况:

任务管理器流程

任务管理器详细信息

To find out which app is being hosted, you can use MainWindowTitle 要了解托管哪个应用程序,可以使用MainWindowTitle

Console.WriteLine(p.ProcessName); // WWAHost
Console.WriteLine(p.MainWindowTitle); // Netflix

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM