I am writing a java code to print current process that is on top of all process.
I write this:-
String process;
Process p = Runtime.getRuntime().exec("tasklist.exe /fo csv /nh");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((process = input.readLine()) != null) {
System.out.println(process);
}
input.close();
it prints all running processes but i want only one process that is on top of all other process and that is currently visible.