Skip to content

Commit 21ae74d

Browse files
author
Ben Wright
committed
Minor changes that provide a simple capture utility, a central place for configuration and a better readme
1 parent 7a87e13 commit 21ae74d

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

capture.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# Benjamin James Wright <bwright@cse.unsw.edu.au>
3+
# This is a simple capture program that will capture a section of
4+
# the screen on a decided interval and then output the images
5+
# with their corresponding timestamps. (Borrowed from stackoverflow).
6+
# This will continue to capture for the seconds specified by argv[1]
7+
8+
import gtk.gdk
9+
import time
10+
import sys
11+
import config
12+
13+
14+
print "Starting Capture"
15+
print "================"
16+
17+
w = gtk.gdk.get_default_root_window()
18+
sz = w.get_size()
19+
20+
for i in xrange(0, config.CAPTURE_NUM):
21+
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
22+
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
23+
if (pb != None):
24+
pb.save("capture/screenshot_"+ str(int(time.time())) +".png","png")
25+
print "Screenshot " + str(i) + " saved."
26+
else:
27+
print "Unable to get the screenshot."
28+
time.sleep(config.CAPTURE_DELAY)

capture/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png

config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# Benjamin James Wright <bwright@cse.unsw.edu.au>
3+
# This configuration file provides really basic settings for the capture system.
4+
5+
6+
# This defines the number of shots to take
7+
CAPTURE_NUM = 20
8+
# This is the delay between screenshots (in seconds)
9+
CAPTURE_DELAY = 1

0 commit comments

Comments
 (0)