Skip to content

Instantly share code, notes, and snippets.

@meoow
Created August 14, 2014 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meoow/fd064db781f802b3d905 to your computer and use it in GitHub Desktop.
Save meoow/fd064db781f802b3d905 to your computer and use it in GitHub Desktop.
Take screenshot
import sys
from PyQt4.QtGui import QPixmap, QApplication
import os
namebase='screenshit_'
num=1
outdir= os.path.abspath(os.path.join(os.environ['HOMEPATH'],'Documents'))
while os.path.exists(os.path.join(outdir,namebase+str(num)+'.png')):
num+=1
fulloutname = os.path.join(outdir, namebase + str(num) + '.png')
app = QApplication(sys.argv)
QPixmap.grabWindow(QApplication.desktop().winId()).save(fulloutname,'png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment