I found this question : Get screenshot on Windows with Python?
to take a screenshot of the full desktop:
import sys
from PyQt4.QtGui import QPixmap, QApplication
from datetime import datetime
date = datetime.now()
filename = date.strftime('%Y-%m-%d_%H-%M-%S.jpg')
app = QApplication(sys.argv)
QPixmap.grabWindow(QApplication.desktop().winId()).save(filename, 'jpg')
However, I would like to take a screenshot of an external window. I have the hwnd of the window I want to take the screenshot off using win32gui.