简体   繁体   English

如何在Linux/macOS上获取C#进程的window标题?

[英]How to get the window title of a process in C# on Linux/macOS?

By default, GUI windows in Windows, Linux and macOS will show the title of the window on top of them and that is what I want to read programmatically with .NET Core 6.默认情况下,Windows、Linux 和 macOS 中的 GUI windows 将在它们之上显示 window 的标题,这就是我想用 .NET Core 6 以编程方式阅读的内容。

On Windows, this can done by getting Process.MainWindowTitle .在 Windows 上,这可以通过获取Process.MainWindowTitle来完成。 However, the documentation of that property states it will most often return an empty string on Unix system and so this what happens on Linux and macOS.然而,该属性的文档指出它通常会在 Unix 系统上返回一个空字符串,所以这就是在 Linux 和 macOS 上发生的情况。

Is there a way to read this information on these systems?有没有办法在这些系统上读取这些信息? A native way to do so without dependencies would be preferred if possible.如果可能的话,最好使用没有依赖性的本地方法。

The short answer is no by default functionality of .NET CORE in Unix简短的回答是 Unix 中 .NET 核心的默认功能没有

You can read the comment by omajid to get an idea您可以阅读 omajid 的评论以获得想法

Get or set the console title in Linux and MacOSX with .NET Core 获取或设置控制台标题 Linux 和 MacOSX with .NET Core

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

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