Running Apps by priority

its easy to get the name of the frontmost process:

tell application "System Events" to set f_proc to name of item 1 of (processes whose frontmost is true)

However, what if i want the 2nd or 3rd process of the priority list, like seen in the Headsup Display, when you do a: cmd+tab ?
how to get such informations ?

All right, its simple i guess - which leads me to the next question: how to use “getpriority” ?

Process priority and application order are two different things. Using launch services you can get the application in the same order as using alt + tab. Process priority has something to do with the task scheduler to determine the priority of the next piece of code to be executed. For instance, even if mail is the front most application it doesn’t have to be the highest priority for the task scheduler.