AppleScript is a scripting language created by Apple to easily control OSX applications. It is really simple to understand but sometimes is hard to find how to do something.

For instance, moving a running application in front of all other applications is pretty easy (once you managed to find who is responsible for that behavior and what keywords you need to use).

tell application "System Events"
    set frontmost of process "Finder" to true
    delay 0.5
end tell

where the word Finder could be the name of any application is currently running.