[英]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.
为此,我需要所有打开的应用程序(而不是进程)的列表,这些列表显示在任务栏中。
Here are some sources to look into: 以下是一些资料来源:
http://www.daniweb.com/web-development/jsp/threads/93197 http://www.daniweb.com/web-development/jsp/threads/93197
http://java.ittoolbox.com/groups/technical-functional/java-l/java-code-required-to-access-task-manager-569041 http://java.ittoolbox.com/groups/technical-functional/java-l/java-code-required-to-access-task-manager-569041
http://www.sqaforums.com/showflat.php?Cat=0&Number=658713&an=0&page=6 http://www.sqaforums.com/showflat.php?Cat=0&Number=658713&an=0&page=6
Looks like you'll be using the Runtime class. 看起来您将使用Runtime类。
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.