Report abuse


			
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'appscript'
include Appscript

#puts app('System Events').processes.frontmost.get
#puts app('System Events').processes.map{ |p| p.get }
puts app('System Events').processes.select.map{ |p| p.name.get if p.frontmost.get }.compact.first

# ...

# rb-appscript fucking good manual/documentation 
#     http://appscript.sourceforge.net/rb-appscript/doc/appscript-manual/index.html





# Applescript Equivalent:
#
# tell application "System Events"
#   set frontmostApplication to name of the first process whose frontmost is true
# end tell