I'm trying to figure out what file is currently open inside of other active applications on Mac OSX. I know that I can find the current applications open via:
NSWorkspace *ws = [[NSWorkspace alloc] init];
NSArray *apps = [ws runningApplications];
// loop through the apps and get the localizedName
However, the "runningApplications" (NSRunningApplication) doesn't provide me with anything related to what's open within that application. So let's say the user has Sublime Text 2 open. I'd like to access that app and see what document(s) (and the related path for that document(s)) they currently have open in it.
I know that applescript and scripting bridge are "options" however, the problem I see with those 2 is the following:
Scripting Bridge requires that you generate and add header files from each application you want to interface with. The problem with this for me is that my application doesn't know what apps the user has in advance. XCode(5) doesn't seem to allow me to generate those on install (i.e. loop thru user's app directory and add the apps) or anything either.
AppleScript, while not as dependent upon knowing what apps you want to work with, doesn't work with all apps. Only certain ones support it.
The end goal here is to be able to look at what apps the user currently has open and get information on what those applications have open at that moment.
Edit: For example - If the user has "/some/dir/example.txt" open with "Text Edit", I'd like to be able to grab that information.
