Sinisterly

Full Version: Screencap Program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This program requires Python 2.7 or 2.1 and every version between.

Dependencies:
  • Python 2.1.X - 2.7.X
  • PIL

Downloads:
PIL - [Click here]

Tutorial:
This is actually a really simple program utilizing PIL.

Imports needed are pretty minimal. You can get very "into-detail" and have a long list of imports to make the absolute best program ever, but this is merely a simplified version of what could be done.

Code:
from PIL import ImageGrab as image
import time

Then we only have two lines to go, technically one if you want to get really spiffy and make this short. However, we're only going for good. Not short.

Code:
name  = time.strftime("%d.%m.%y_%H.%M.%S", time.localtime(time.time()))

Basically we just have Python grab the current time and data, this will be our file name. Once it is grabbed the output will be as follows:
Spoiler:
3.9.2014_11.04.55

Next we just grab the image and save it with a file type. This is fairly simple since we imported ImageGrab as image, we won't have to be using and capitalization or of the sort. Typos should be fairly inevitable because of this, but can still spawn.

Code:
image.grab().save(name + '.PNG')

We're finished with our four simple lines of code to making a screencap program. Whenever you run it, it will capture your screen and save it. What you could do is save it as a .pyw file and bind a macro to it, but why would you need to? There's already a screencap on Windows and Mac. (Windows is Prt Scr) The difference between the print screen button and this program is that you don't need to copy and paste this into an editor such as MSpaint (ew) and save it. It does it automatically.

Also, be aware of where you save this file, your screenshots will be saved in the same location. Of course you can change that and add your own location, but this is just a simple program, we won't get into too much detail.

Images saved with this program will be saved as follows:
Spoiler:
3.9.2014_11.04.55.png

Code:
from PIL import ImageGrab as image
import time
name  = time.strftime("%d.%m.%y_%H.%M.%S", time.localtime(time.time()))
image.grab().save(name + '.PNG')

That's all for this tutorial, hope this helped if you were trying to make a program of this sort.