You can use NSWorkspace's runningApplications
method and NSRunningApplication's launchDate
property to get you close to what you need.
Check out what the output if this code bit looks like in your console:
NSArray * arrayOfRunningApps = [[NSWorkspace sharedWorkspace] runningApplications];
if(arrayOfRunningApps)
{
for(NSRunningApplication * aUserApp in arrayOfRunningApps)
{
NSLog( @"%@ launch time is %@", [aUserApp localizedName], [aUserApp.launchDate description] );
}
}
As for sorting on some criteria, that's really up to your implementation to do.
A couple caveats: these api's were introduced as of Snow Leopard (10.6) and
they only work on apps that the user can see (in the dock), not UNIX processes or admin/root daemons or whatever.
And I'm not certain about Applescript yet, but I'm hoping you'll be able to use this information to get to where you need to go.