Do you have a reason to take a screenshot, i.e. having Photoshop UI included in the shot? Can you explain what you are trying to achieve more closely. Why do you take a screenshot of a file you load to be saved to a file, what changes?
In general I'd recommend to use Photoshop scripting to automate what you would do manually in Photoshop like
1) Open template document
2) Open content document
3) Duplicate content layer in template and position it
4) Duplicate template doc
5) Flatten the duplicate and save to disk
6) Delete content layer from template and close content doc
7) go to 1)
Thanks for the response Matias.
I am trying to compare a set of files based on how they are rendered in PS vs how they are rendered in some other application. I don't intend to save the file again, was just opening it. I fear that the output I get on flattening the doc might be different from what is seen when the document is opened. Could that happen, or should I go ahead with the flattening workflow?
I would say flattening is more reliable, i.e. then it does a render to specific resolution and should work the same way in any computer with same version of PS. However screenshot depends on monitor resolution, window size, possibly even graphics card drivers (i.e. if Photoshop is compatible with using HW acceleration in your card or not). Try zooming a bigger than screen doc in and out and you'll see pretty big distortions depending on zoom level. I'd try.
But the question is how not why.
Try adding an app.refresh() after opening your documents.