Advertisement
Guest User

comparedirs

a guest
Aug 14th, 2010
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. import gtk.gdk
  2. import os
  3. import time
  4.  
  5. basedir = os.path.join(os.path.expanduser("~"), "screenguard")
  6. timeformat = '%d.%m.%Y %H:%M:%S'
  7.  
  8. if not os.path.exists(basedir):
  9.     os.mkdir(basedir)
  10.  
  11. collect_size = 50
  12. collect_index = 0
  13. oldsec = time.localtime().tm_sec
  14. print time.localtime().tm_sec
  15. #feststellen, wo aufgehoert: dort weitermachen
  16.  
  17. collect_index = 0 #begin after the last file
  18. while 1:
  19.     if os.path.exists(os.path.join(basedir, "screenshot%04d.png" % collect_index)):
  20.        collect_index += 1
  21.     else:
  22.         break
  23. #option: destination path
  24.  
  25. while 1:
  26.     w = gtk.gdk.get_default_root_window()
  27.     sz = w.get_size()
  28.     print sz
  29.     print "The size of the window is %d x %d" % sz
  30.  
  31.     pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,1280,sz[1])
  32.     pb = pb.get_from_drawable(w,w.get_colormap(),1280,0,0,0,1280,sz[1])
  33.  
  34.     newfilename = os.path.join(basedir, "screenshot%04d.png" % collect_index)
  35.     if os.path.exists(newfilename): #delete old file before
  36.         os.remove(newfilename)
  37.     if (pb != None):
  38.       pb.save(newfilename, "png") # option for file format # hier erst exension dazu (optparse)
  39.       #pb.save(newfilename, "jpeg", {"quality":"40"}) #bringt eh nicht viel
  40.  
  41.       print "Screenshot saved to %s" % newfilename
  42.     else:
  43.       print "Unable to get the screenshot.", time.strftime(timeformat)
  44.     collect_index += 1
  45.     if collect_index >= collect_size:
  46.         collect_index = 0
  47.  
  48.     while 1: #print one sreenshot each second
  49.         if time.localtime().tm_sec != oldsec:
  50.             break
  51.         else:
  52.             time.sleep(0.1) #give time for other things
  53.  
  54.     oldsec = time.localtime().tm_sec
  55.     print time.localtime().tm_sec
  56.  
  57.     #todo keypress event: "q" oder "Q" oder "x" oder "X" => abbruch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement