Getting the list of running applications ordered by last use
Maybe something like this:
cd /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework
nm LaunchServices | grep __LSCopyApplicationArrayInFrontToBackOrder
It is impossible to get the list before your application launches. After you start the application though, you can just register for notifications and maintain your own array of applications.
The only solution is to start a background process at login using launchd that simply listens for applications.
You need to register for notifications when the active application changes, as outlined here: http://www.unsanity.org/archives/000045.php
Once that is done it is easy to maintain an array of active applications sorted by last active time.