Find out what's the frontmost document (of all applications)?

Hello Forum,

is there a way to find out what’s the frontmost document of all running applications via AppleScript?
And further I want to find out the path to this document, in case it was already saved, if possible.
The solution for both should be able to work for non-scriptable as well as for scriptable applications.

Maybe I could use the shell command lsof for the second part?

Many thanks in advance for your help & ideas :slight_smile:

Domink

Hmm… not sure how to get the frontmost document - but this will get you the frontmost process…but as far as getting the frontmost documnet - that will be more difficult…I don’t know how I would even start doing that.

lsof - may be a good place to look for the path though - if you can get the other info.

tell application "Finder"
	get name of every process whose frontmost is true
end tell

Many thx - that’s exactly the problem i don’t find a solution for :wink:
I could try to ask the frontmost app for it’s “document 1” but that will not work in any application …