My recent applescript development required different action based on what application was currently active. Surprisingly, there is no good result for this from google. I pulled this out of a Daring Fireball code example (Writing AppleScripts That Dynamically Target Either Safari or WebKit) and am showcasing it so that others who are looking for the functionality can find it without too much effort.
on GetCurrentApp()
tell application "System Events"
set _app to item 1 of (every process whose frontmost is true)
return name of _app
end tell
end GetCurrentApp
set _app to GetCurrentApp()
tell application "System Events"
set _app to item 1 of (every process whose frontmost is true)
return name of _app
end tell
end GetCurrentApp
set _app to GetCurrentApp()