obout Capture

Asked by Chp on 2017-05-15

1. The capture() method returned the path to the file before, but now it returns an ScreenImage object. Is it correctly?
2. What is the difference between capture() and userCapture() method?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

Supposing you are talking about the Java level API, ...

at 1: ... then yes, Screen.capture() returns a ScreenImage object, that in turn has some methods to save the content and to access the BufferedImage directly.

at 2: capture() silently captures the given region, whereas userCapture() is the interactive capture feature, that allows the user, to define the region to be captured by dragging over the screen.


Chp (chpnick) said : #2

1. my code:
from sikuli.Sikuli import *
scr = Screen()
bound = scr.getBounds()
# create .png screenshot file in %TEMP% dir
scr_name = scr.capture(x, y, w or bound.width, h or bound.height)

 returned the path to the file before, now it returns an ScreenImage

i noticed, you deprecated class Screen.py. is it True?

2 Thank you

Sorry fo my bad english))))

RaiMan (raimund-hocke) said : #3

in Sikuli(X) up to version 1.x it is not recommended to use the Java notation like scr.capture(), since internally all non-dotted methods are automatically bound to the object SCREEN, which is initialized as Screen(0).

So for version 1.1.x (recommended in any case) this works as expected:
scr_name = capture(...whatever allowed...)

so your snippet should read:
from sikuli import * # only needed in imported files or with plain Jython
# create .png screenshot file in %TEMP% dir
scr_name = capture(SCREEN)

Chp (chpnick) said : #4

Thank you