R – Use AppleScript or other Mac OS method to get filename and path of open files


Is there any way to use AppleScript (or something else) to query currently running applications for the filename and path of the current file that they have open? I know some applications show the filename in the window title which is script accessible, but this isn't a solution as not all do, and hardly any show the path. I also know this is complex because not every application is document based.

Any suggestions on how to find the currently opened file/path in running Mac apps would be appreciated. Thank you!

Related Question