on run tell prevAppTest to run end run script prevAppTest set CR to return as text display dialog "Will give you 4 seconds to switch to another application." & CR & ¬ "If that app is Safari or prevApp (this one), then we won't switch back to it after dialogs." delay 4 tell application "Finder" set prevAppName to ¬ (name of application processes whose frontmost is true) as string -- the "as string" bit there is most important end tell tell me to activate display dialog prevAppName & " = Safari :: " & (prevAppName is equal to "Safari") display dialog prevAppName & " = prevApp :: " & (prevAppName is equal to "prevApp") -- prevAppName better be a string, or it can't be equal to any string if (prevAppName is equal to "Safari") or (prevAppName is equal to "prevApp") then -- don't switch back display dialog "not switching" giving up after 5 else -- switch back display dialog "yes, switching to prevApp: \"" & prevAppName & "\"" giving up after 5 tell application "Extra Suites" say "switching" ES type key "tab" with command end tell end if display dialog "da-da da-da!" giving up after 10 end script