Question #233507 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/233507

Giuseppe Marullo posted a new comment:
While I am learning Java, here it is

FindAllImages(infolder)

RaiMan, I got the getLastMatch optimization but cannot stand break, so I
left the while...

Hopefully you will have a better implementation on 1.1, in the meantime:

public static boolean FindAllImages(Screen k, String path, Float similarity, 
int timeout) {
    int result;
    
    File pathimages = new File(path);
    File [] files = pathimages.listFiles();
    
    boolean iconfound = false;
    Integer i = 0;
    try{
      
      while ( (i < files.length) && (iconfound == false )) { 
        Pattern ccleanericon = new Pattern(files[i].getAbsolutePath());
        
        if (k.exists(ccleanericon.similar(similarity),timeout)!= null) {
          System.out.println("Found " + files[i].getAbsolutePath() );
          Match m = k.getLastMatch();
          m.highlight(2);        
          k.doubleClick(ccleanericon);
          iconfound = true;
        }
        else {
          System.out.println("Not Found " + files[i].getAbsolutePath());
        }        
        i = i + 1;
      } // end of while      
    }
    catch(FindFailed e){
      e.printStackTrace();
    }
    return iconfound;   
  }
  
Cheers!

Giuseppe Marullo

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to