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.
2 Answers
Here are some sources to look into:
http://www.daniweb.com/web-development/jsp/threads/93197
http://www.sqaforums.com/showflat.php?Cat=0&Number=658713&an=0&page=6
Looks like you'll be using the Runtime class.

- 2,589
- 3
- 31
- 49
None of your links CFL_Jeff says anything of how to get active application windows (which I assume is what you want?
Don't think this can be accomplished with java or a simple windows commandline.
Here might be a way to do it in C#: Get the list of opened 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
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.
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());}
-
is there any java api available which can be used to access winapi? – mak Mar 13 '12 at 13:17