Mac / Cocoa - Getting a list of windows using Accessibility API
accessibility, cocoa
Solution
Use `AXUIElementCopyAttributeValues` to copy the value for `kAXWindowsAttribute`, which should be an array of AXUIElement objects representing the application's windows.
As you can guess from its function name, it follows the copy rule.
Problem
I want to use the Accessibility API to get a list of all windows for a given application (external). The goal is to check if a certain window is open. First I check that the application is running (using [NSWorkspace runningApplications] and checking each one), and then I want to check the title bar text of each window that is open for that application. PS So I can create an element for the app using the PID: ``` AXUIElementRef app = AXUIElementCreateApplication(pid); ``` but what do I do with it? Am I even going in the right direction? Can't beleive it's so hard to find examples on this.