Capture screenshot without IDE

Asked by Djg

Hi,

1. How do i capture screenshots without using the sikuli IDE?
2. Will CTRL+SHIFT+2 work if we run sikuli via command line?
3. How do i capture screenshots will using eclipse?
4. Is there any API to capture screenshots and do the same/similar functionality that "take snapshot" button does in sikuli IDE?
I am asking this question as i want to create an IDE for my project and want to include this feature in it?

Thanks!!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

You can always use the Sikuli IDE to capture and store your images.

A .sikuli, containing all your images can be imported, so all images are available in your script when using the Jython layer. From Java it is just filenames. You should have a naming convention for your images.

Since the capture in the end is a simple 5 liner (or less ;-) based on the Java Robot and image-io, you might integrate this function in a Java based app easily. Or you might just use Sikuli's capture function that in the first run returns an image in memory.

You have to look into the sources, because this it not a publicly documented API.

Revision history for this message
Djg (gdeepakjain) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
Enix Shen (enix12enix) said :
#3

since you use python, another choice is using PIL lib to capture the pic. But this lib is just for windows.

see here http://www.pythonware.com/products/pil/

Example code:
from PIL import ImageGrab
ImageGrab.grab().save("screen_capture.jpg", "JPEG")

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@ Enix
PIL is a C-based Python module and cannot be used in Sikuli's Jython environment