Possible Duplicate:
Take a screenshot via a python script. [Linux]
How can I achieve the capturing screen-shots and saving in a folder as achieved by the following python code in windows in linux (ubuntu)? I also want to run it at the OS start-up.
import os
import sys
import time
import Image
import ImageGrab
SaveDirectory=r'C:\Documents and Settings\gg\Desktop\office_docs'
———————————————————
for i in range(10000):
img=ImageGrab.grab()
saveas=os.path.join(SaveDirectory,'ScreenShot_'+time.strftime('%Y_%m_%d_%H_%M_%S')+'.png')
img.save(saveas)
time.sleep(10)
The first thing you should do, is replace the path of SaveDirectory with a path that works on both operating systems.
Based on How to get the home directory in Python?, you can use os.path.expanduser to replace ~ with your home directory.
A possible solution is:
For the second part of the question, it depends whether you want to do it via a GUI or manually editing a config file. Here you should find the instruction for the GUI. Here you can find the instructions for the config file way.
I should note that the python style guide suggest lowercase names with words separated by underscores for instance variables since it improves readability, but this is just a suggestion.
I hope you find this answer useful and apologise if it does not work as I have not tested it myself.