简体   繁体   English

如何使用Java在Windows中找到当前打开的应用程序(在任务栏上)的名称?

[英]how to find the names of currently opened applications (on taskbar) in windows, using java?

I'm making an application which is like windows task manager. 我正在制作一个类似于Windows任务管理器的应用程序。 For that, I need the list of all opened applications (not processes), which are shown in taskbar. 为此,我需要所有打开的应用程序(而不是进程)的列表,这些列表显示在任务栏中。

None of your links CFL_Jeff says anything of how to get active application windows (which I assume is what you want? 您的链接都没有CFL_Jeff提到如何获取活动的应用程序窗口(我想这就是您想要的?)。

Don't think this can be accomplished with java or a simple windows commandline. 不要以为这可以通过Java或简单的Windows命令行来完成。

Here might be a way to do it in C#: Get the list of opened windows C# 这可能是在C#中执行此操作的一种方法: 获取已打开的Windows C#的列表

Or you might have to take a look here: http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919%28v=vs.85%29.aspx 或者,您可能必须在这里看看: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/ff468919%28v=vs.85%29.aspx

An emergency solution might be to use the "tasklist /v" command and get all processes that have a "windowtitle" that differ from "I/T"(might be locale dependent), but that will give you tray icons aswell I'm afraid. 紧急解决方案可能是使用“ tasklist / v”命令并获得所有具有“ windowtitle”的进程,这些进程不同于“ I / T”(可能取决于语言环境),但这也会为您提供任务栏图标害怕。

Edit: To get the tasklist, you can use the following: 编辑:要获取任务列表,可以使用以下命令:

try
{
    Process p = Runtime.getRuntime().exec("cmd /c tasklist /v");
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String input;
    while ((input = stdInput.readLine()) != null)
    {
        output += input;
    }
    stdInput.close();
}
catch(Exception k){JOptionPane.showMessageDialog(null, k.getMessage());}

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

相关问题 如何在Windows上使用Java正确实现SystemTray /固定任务栏应用程序 - How to correctly implement SystemTray/Pinned Taskbar applications on Windows with Java 预览 window(与 Windows 一样,打开的应用程序显示 7 个任务栏) - Preview window (like Windows 7 taskbar shows for opened applications) 如何使用java代码在windows(任务管理器->应用程序)中获取打开的应用程序列表? - How to get opened applications list in windows(taskmanager ->application) using java code? Java打开的应用程序找不到目录 - Java opened applications can't find directories 如何在Android中以编程方式查找当前正在运行的应用程序? - How to find the currently running applications programmatically in Android? 在 Java 中隐藏 Windows 任务栏? - Hide Windows taskbar in Java? Java程序和Windows任务栏 - Java Program and Windows Taskbar Java-使用JNA的Windows任务栏-如何将窗口图标(HICON)转换为Java图像? - Java - Windows taskbar using JNA - How do I convert window icons (HICON) to java images? Android:获取当前打开的应用程序的堆栈(数组) - Android: Get the stack (array) of currently opened applications 如何关闭单个 excel 文件,而不是当前使用 java 打开的所有 excel 文件 - How to close a single excel file, not all excel files which are currently opened using java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM