I am trying to take a screenshot in the current window using python script in linux.
Now I have a script that 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 I would like to have only the selected window. I know the problem comes from grabWindow. But I do not know how to solve it.
source share