← Back to team overview

sikuli-driver team mailing list archive

[Question #268579]: Java API - How to sort matches in Java IDE

 

New question #268579 on Sikuli:
https://answers.launchpad.net/sikuli/+question/268579

Hello, Dear Colleagues.
I wrote code in Sikuli IDE with two requirements:
1).  Sort all matches, returned with findall() method;
2). Click on all matches except the last.

But I cannot implement perform none of these two conditions in Java IDE: it clicks on all images and in random order.
Could you please help me with that? Thanks.

Code:

          Clicker.java:
package sikuli;

import java.util.Iterator;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class Clicker {
    static Screen scr1 = new Screen(0);
    static String path = "images.sikuli\\plus.png";
    static Pattern pat = new Pattern(path).similar(0.95f);
    static int count = 0;
    public static void clicker(){
        try{
           Iterator<Match> matches = scr1.findAll(pat);
           for (; matches.hasNext(); matches.next()) {
                count++;
                Match m = matches.next();
                System.out.println(m);
                scr1.click(m);
                clicker();
               break;
            }
        }
        catch(FindFailed e){
            e.printStackTrace();
        }
    }
}


          Sikuli.java:
package sikuli;

import org.sikuli.script.*;

public class Sikuli {
    public static void main(String[] args) throws FindFailed{
       Clicker.clicker();
       System.out.println(Clicker.count);
    }
}



-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.