find frontmost app from script menu

this seems like a silly problem, but it’s got me stumped. I want a script to runs from the script menu that quits every visible process except the frontmost. seems easy, except when I try to access the frontmost process from the script menu it tells me that it’s “System Events”, and shuts everything down. how do I access the name of the process that was frontmost when I called the script (and will be again as soon as the script ends), but doesn’t seem to be while the script runs?

if that makes any sense…

Operating System: Mac OS X (10.4)

You can use:

tell application "Finder" to ¬
	name of file (path to frontmost application as text)


very interesting - thanks. :slight_smile: