obout Capture

Asked by Chp

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

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Chp
Solved:
Last query:
Last reply:
Revision history for this message
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.

see:
https://raiman.github.io/SikuliX-2014/javadocs/index.html

Revision history for this message
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))))

Revision history for this message
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)

Revision history for this message
Chp (chpnick) said :
#4

Thank you