views:

73

answers:

2

I have a need to enumerate the applications that have "windows", "icons", whether if they are minimized to the dock or not. I need basically the list of applications that Command-TAB brings you. How do you do this programmatically?

Everything I tried gave me everything, or just the applications that are NOT minimized. Drives me nuts. Tried CGWindowListCopyWindowInfo, NSArray *runningApps = [workspace launchedApplications], but I can't get to the filtering of the list I need - whatever Cmd-TAB brings you.

A: 

You might try -[NSWorkspace runningApplications] which is available since 10.6. It gives the list of NSRunningApplication, whose properties can be inspected to some extent. I'm afraid it might not give you what you want, though.

Yuji
+1  A: 

This was asked and answered previously here: http://stackoverflow.com/questions/945033/getting-the-list-of-running-applications-ordered-by-last-use

Joshua Nozzi
But beware that the accepted answer to that question is a private API, which therefore might break on any given software update.
JWWalker
Thanks. Now I am using this to receive a list of running applications:NSArray *launchedApps = [[NSWorkspace sharedWorkspace] launchedApplications];Now I want to enumerate the windows open (or minimized) under each application. I'm particularly interested in the Window Name (e.g. the text on the caption) and the window ID. The application name needs to be the "key" by which I do this.I'd appreciate it if anyone could point me in the right direction.
Ron M.
I believe the only way to do this is with the Accessibility Framework.
Joshua Nozzi