Return focus to previous app?

Is there any way (natively in BTT or via AS/JS) to switch back to the previously active application?

I have a scheduled event that opens Safari via AppleScript and runs a script. The process is in the background, but during the initial activation of Safari, the current app loses focus. If I could restore focus to whatever had focus prior to this script, that would be awesome. Since it is a scheduled event, I obviously don't know what app will be active, so I need a way to save this info prior to the script running, and then restore focus once the script is running.