I have been using the JNA library to get all visible window handles in Windows. I need to do something similar in macOS using JNA.
Here is code to get all window handles in Windows:
public static List findAll() {
final List windows = new LinkedList<>();
User32.INSTANCE.EnumWindows(new User32.WNDENUMPROC() {
@Override
public boolean callback(HWND hWnd, Pointer arg) {
if (User32.INSTANCE.IsWindowVisible(hWnd)) {
windows.add(hWnd);
}
return true;
}
}, null);
return windows;
}
What is the equivalent code in macOS?
解决方案
You'll need to map portions of the Core Graphics Framework. You can list windows using the CGWindowListCopyWindowInfo() function.
To load the framework you'll need to map a CoreGraph