How to automate the screen capture of an application window??

I am working on a regression QA tool for some DVD authoring work. I have created a script that interacts with the dvd and I want to take screen captures of the application window at its native resolution, not the whole monitor. I have yet to find a way to capture a window image with out a user click required. I have tried GUI scripting and Extra Suites to no avail. Unfortunately once the screencapture -iW command is executed the applescript will not proceed to the next command until a window has been clicked by the user.

does anybody have any ideas on how I can fully automate this?