I'm trying to take a screenshot of the curent window using a python script on linux.
I curently have a script which takes a screenshot of the entire screen:
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')
But a would like to have only the selected window. I know that the problem comes from grabWindow. But I don't know how to resolve it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…