<dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>5.6.0</version> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna-platform</artifactId> <version>5.6.0</version> </dependency>
public static void showWindow(){ final User32 user32 = User32.INSTANCE; user32.EnumWindows((hWnd, arg1) -> { char[] windowText = new char[1000]; User32.INSTANCE.GetWindowText(hWnd, windowText, 5120); String wText = Native.toString(windowText); boolean b = User32.INSTANCE.IsWindowVisible(hWnd); if (wText.isEmpty()) { return true; } System.out.println(wText); return true; }, null); }
获取窗口宽高、移动窗口
public static void main(String[] args) { WinDef.HWND hwnd = User32.INSTANCE.FindWindow(null,"D:\\360MoveData\\Users\\Administrator\\Desktop\\工作.txt - " + "Notepad++"); WinDef.RECT rect = new WinDef.RECT(); User32.INSTANCE.GetWindowRect(hwnd,rect); User32.INSTANCE.MoveWindow(hwnd,100,100,1200,800,true); int left = rect.left; System.out.println(left); //showWindow(); }
标签:WinDef,窗口,INSTANCE,jna,windowText,User32,windos,left From: https://www.cnblogs.com/qq376324789/p/17553569.html