OS X: is it possible to open a window on top with AppleScript? So I have this little script that, when launched does a screenshot of the current screen and then fires up an image editor to edit the image. However, I noticed that every time the editor is being fired up, it just hangs in the background — as in, it doesn't pop up on my screen so sometimes I just sit there wondering what the hell when I suddenly realize I need to do the edits for script to go on and that the image editor is already waiting on me to find it in Dock. Is there a way to make it start on top of other windows?
Use tell application "name" to activate, where name is the name of the application you want brought to the front. If you already have a tell statement block for the target application you can use activate by itself within the tell statement block.

Examples:

tell application "name" to activate


Or:

tell application "name"
    activate
    # Other commands to follow...
end tell


Also, if the target app is being opened from within a shell script, whether executed manually in Terminal or within AppleScript e.g. do shell script "name.sh ..." you can add an AppleScript command within the shell script using osascript as in the following:

Syntax:

osascript -e 'tell application "name" to activate'


Example:

osascript -e 'tell application "Safari" to activate'


Note: In Terminal, type man osascript and press enter, to display the BSD General Commands Manual entry for osascript.



From the AppleScript Language Guide:


  activate
  
  
  
  Brings an application to the front, launching it if necessary.




As a good reference, have a look at Introduction to AppleScript Language Guide and the following document is handy to have on your system, AppleScript Language Guide (2013) PDF.