How to define a region by screenshot?

Asked by Steven Sheldon

Hi,
I want to search for a region, so that I can then search within that region later.

I am using this command:

region = Region("1738863287150.png")

The .png file is generated when I clicked the "Take screenshot" button and defined the area I want to look at.

This is the error I am getting:
[error] script [ Tab and Slot ] stopped with error in line 1
[error] TypeError ( org.python.proxies.sikuli.Region$Region$3(): 1st arg can't be coerced to org.sikuli.script.Region, boolean, java.awt.Rectangle )
[error] --- Traceback --- error source first
line: module ( function ) statement
1: main ( <module> ) region = Region("1738863287150.png")
[error] --- Traceback --- end --------------

What is wrong?

Question information

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

Try

region = screen.find("1738863287150.png")

Revision history for this message
Steven Sheldon (ssheldon12345) said :
#2

I tried:
command_region = screen.find("1738875604030.png")

And I get this error:
[error] script [ Tab and Slot 2 ] stopped with error in line 2
[error] NameError ( name 'screen' is not defined )
[error] --- Traceback --- error source first
line: module ( function ) statement
2: main ( <module> ) region = screen.find("1738875604030.png")
[error] --- Traceback --- end --------------

Revision history for this message
Steven Sheldon (ssheldon12345) said :
#3

OK, evidently, this does not work:

from sikuli import *

But this does:

from sikuli import Screen

Revision history for this message
Steven Sheldon (ssheldon12345) said :
#4

Thanks Manfred Hampl, that solved my question.