如何使用java在Windows中查找当前打开的应用程序(在任务栏上)的名称? [英] how to find the names of currently opened applications (on taskbar) in windows, using java?

查看:511
本文介绍了如何使用java在Windows中查找当前打开的应用程序(在任务栏上)的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个类似于Windows任务管理器的应用程序。为此,我需要所有打开的应用程序(不是进程)的列表,它们显示在任务栏中。

I'm making an application which is like windows task manager. For that, I need the list of all opened applications (not processes), which are shown in taskbar.

推荐答案

没有你的链接CFL_Jeff说了如何获取活动应用程序窗口(我假设你想要的是什么?)

None of your links CFL_Jeff says anything of how to get active application windows (which I assume is what you want?

不要认为这可以通过java或简单的Windows命令行完成。

Don't think this can be accomplished with java or a simple windows commandline.

这可能是在C#中实现的一种方式:
获取已打开的窗口列表C#

Here might be a way to do it in C#: Get the list of opened windows C#

或者您可能需要查看此处:
http ://msdn.microsoft.com/en-us/library/windows/desktop/ff468919%28v=vs.85%29.aspx

Or you might have to take a look here: http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919%28v=vs.85%29.aspx

紧急解决方案可能是使用tasklist / v命令并获取具有与I / T不同的windowtitle的所有进程(可能是区域设置依赖ent),但这会给你托盘图标以及我害怕。

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.

编辑:
要获得任务列表,您可以使用以下内容:

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());}

这篇关于如何使用java在Windows中查找当前打开的应用程序(在任务栏上)的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆