Image reconition not working after using screen.setRect() --- screen needs to be reset to whole screen

Asked by Mohammed Saquib on 2018-03-17

Installed using 2 & 3 option checked

Settings.OcrTextRead = true;
   Settings.OcrTextSearch = true;

   for(int i = 0; i < 4; i++) {
    Rectangle rectangle = new Rectangle(500, 550+(i*25), 75, 20);
    String xx= screen.text();
    xx= xx.substring(1);

   Settings.OcrTextRead = false;
   Settings.OcrTextSearch = false;
   Pattern scrollDown = new Pattern(iconPath + "scrolldown.png");

FindFailed: D:/Users/xxxx/xxxxxx/images/scrolldown.png: (74x21) in S(0)[0,0 1366x768] E:Y, T:3.0
  Line 2759, in file

Question information

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

the problem is this:

which means that on the screen it is searched only in the given rectangle.

after the loop, you have to reset the screen object:
screen = new Screen()

to restore to the whole screen.

generally it is not recommended to use screen.setRect(), since this may lead to such quirks if not reset and may be hard to debug.

--- better:
for(int i = 0; i < 4; i++) {
    //Rectangle rectangle = new Rectangle(500, 550+(i*25), 75, 20);
    Region reg = new Region(500, 550+(i*25), 75, 20);
    //String xx= screen.text();
    String xx= reg.text();
    xx= xx.substring(1);

Can you help with this problem?

Provide an answer of your own, or ask Mohammed Saquib for more information if necessary.

To post a message you must log in.