[Java] how to use findAll in Java

Asked by Kristian Karl

Hi,

When I'm running a simple scenario in the Sikuli-X rc1 ide:

  with findAll("star.png") as mm:
      while mm.hasNext(): # loop as long there is a first and more matches
          print "found: ", mm.next()

it works as expected.

But when I'm running the same scenario in java [using sikuli-script.jar]:

    try {
      Iterator<Match> matches = screen.findAll("star.png");
      for (; matches.hasNext();) {
        count++;
      }
    } catch (FindFailed ex) {
      printStackTrace();
    }

It 'hangs' for a looong while in findAll, and eventually returns millions of hits....
Am I using it wrong? Has anybody encountered this?

Everything else works fine in java, like find, wait, click, doubleclick

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Kristian Karl
Solved:
Last query:
Last reply:
Revision history for this message
Kristian Karl (kristian-hermann-karl) said :
#1

...and yeah, I now see I have a bug:

      for (; matches.hasNext();) {
        count++;

should be:

      for (; matches.hasNext();matches.next()) {
        count++;

And for some reason I cannot reproduce the 'hang' in findAll
So, sorry for the noise people.