How to open/activate the main window of an app?

I’m trying to make a script so to play the next song, and I need to activate the main window to do it. How do you do it, short of “graphically” scripting the Dock via Assistive Devices so it’s clicked? I know it’s possible, because Spark seems to do it automatically when you make a shortcut to launch an app.

I think I figured it out. It’s not actually AppleScript, but this is the best I could find. Definitely beats the Dock clicking hack:

do shell script "open -a"