how to get windows of NSRunningApplication

cocoa, nsapplication, nsrunningapplication, nsworkspace

Solution

You need to look at the CoreGraphics call `CGWindowListCopyWindowInfo`.

You call it like this

    CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);

and then iterate over the array of window information, find the ones that are from the application you're interested in, and do what you want with it.

Problem

I want to get the window list for a running application. I can get the running application list from `[[NSWorkspace sharedWorkspace] runningApplications]`, but the window list is only available on `NSApplication`. Is there some way to convert from `NSRunningApplication` to `NSApplication`, or some way to get the window list more directly?

Original source

Related problems