How to get a list of current open windows/process with Java?

后端 未结 14 1338
抹茶落季
抹茶落季 2020-11-22 05:20

Does any one know how do I get the current open windows or process of a local machine using Java?

What I\'m trying to do is: list the current open task, windows or

14条回答
  •  感情败类
    2020-11-22 05:53

    package com.vipul;
    
    import java.applet.Applet;
    import java.awt.Checkbox;
    import java.awt.Choice;
    import java.awt.Font;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.ArrayList;
    import java.util.List;
    
    public class BatchExecuteService extends Applet {
        public Choice choice;
    
        public void init() 
        {
            setFont(new Font("Helvetica", Font.BOLD, 36));
            choice = new Choice();
        }
    
        public static void main(String[] args) {
            BatchExecuteService batchExecuteService = new BatchExecuteService();
            batchExecuteService.run();
        }
    
        List processList = new ArrayList();
    
        public void run() {
            try {
                Runtime runtime = Runtime.getRuntime();
                Process process = runtime.exec("D:\\server.bat");
                process.getOutputStream().close();
                InputStream inputStream = process.getInputStream();
                InputStreamReader inputstreamreader = new InputStreamReader(
                        inputStream);
                BufferedReader bufferedrReader = new BufferedReader(
                        inputstreamreader);
                BufferedReader bufferedrReader1 = new BufferedReader(
                        inputstreamreader);
    
                String strLine = "";
                String x[]=new String[100];
                int i=0;
                int t=0;
                while ((strLine = bufferedrReader.readLine()) != null) 
                {
            //      System.out.println(strLine);
                    String[] a=strLine.split(",");
                    x[i++]=a[0];
                }
        //      System.out.println("Length : "+i);
    
                for(int j=2;j
       You can create batch file like 
    

    TASKLIST /v /FI "STATUS eq running" /FO "CSV" /FI "Username eq LHPL002\soft" /FI "MEMUSAGE gt 10000" /FI "Windowtitle ne N/A" /NH

提交回复
热议问题