Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用java查找处于最小化状态的运行应用程序?_Java_Windows_Jna - Fatal编程技术网

如何使用java查找处于最小化状态的运行应用程序?

如何使用java查找处于最小化状态的运行应用程序?,java,windows,jna,Java,Windows,Jna,如何使用java查找windows桌面上所有正在运行的应用程序处于最小化状态?您需要首先jna.jar和platform.jar并将它们添加到类路径中。通过查看,您可以了解要进行的Windows系统调用 下面是要在所有最小化窗口上枚举的代码: import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platfor

如何使用java查找windows桌面上所有正在运行的应用程序处于最小化状态?

您需要首先jna.jarplatform.jar并将它们添加到类路径中。通过查看,您可以了解要进行的Windows系统调用

下面是要在所有最小化窗口上枚举的代码:

import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinUser.WINDOWINFO;
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;

public class Minimized {
    private static final int MAX_TITLE_LENGTH = 1024;
    private static final int WS_ICONIC = 0x20000000;

    public static void main(String[] args) throws Exception {
        User32.EnumWindows(new WNDENUMPROC() {
            @Override
            public boolean callback(HWND arg0, Pointer arg1) {
                WINDOWINFO info = new WINDOWINFO();
                User32.GetWindowInfo(arg0, info);

                // print out the title of minimized (WS_ICONIC) windows
                if ((info.dwStyle & WS_ICONIC) == WS_ICONIC) {
                    byte[] buffer = new byte[MAX_TITLE_LENGTH];
                    User32.GetWindowTextA(arg0, buffer, buffer.length);
                    String title = Native.toString(buffer);
                    System.out.println("Minimized window = " + title);
                }
                return true;
            }
        }, 0);
    }

    static class User32 {
        static { Native.register("user32"); }
        static native boolean EnumWindows(WNDENUMPROC wndenumproc, int lParam);
        static native void GetWindowTextA(HWND hWnd, byte[] buffer, int buflen);
        static native boolean GetWindowInfo(HWND hWnd, WINDOWINFO lpwndpl);
    }
}