Thanks again for the challenge ;-) Of course this is possible in Python/Jython ... ... and here is a rather basic solution
you can: - add as many images to be searched in parallel - give each one an individual wait time - stop all running searches, if you want at any time import thread # the threadable find function def tfind(parms): global shouldStop end = time.time()+parms.get("waittime", 3) # standard wait time 3 seconds reg = parms.get("region", SCREEN) # standard region whole screen parms["match"] = None parms["finished"] = False while (not shouldStop) and time.time()<end: if reg.exists(parms["pattern"], 0): parms["match"] = reg.getLastMatch() break parms["finished"] = True # setup a pattern list to be paralleled pats = [] # model pattern: {"pattern": some image or pattern, "waittime": seconds, "region": some region} pats.append({"pattern":"1352549030079.png"}) pats.append({"pattern":"1352551675237.png", "waittime":10}) pats.append({"pattern":"1352551662476.png"}) # start the threads shouldStop = False for p in pats: thread.start_new_thread(tfind, (p,)) #wait for termination end = time.time()+5 # search max 5 seconds while True: # stop searches if global search time elapsed if time.time() > end: shouldStop = True print "search stopped" wait(2) # give time to the threads to stop break # wait until all threads have terminated ended = True for p in pats: ended = ended and (p.get("finished", False)) if ended: print "search ended normally" break # check results for p in pats: if p["match"]: p["match"].highlight(1) else: print "not found:", p["pattern"] Happy scripting ;-) I will implement this in the Sikuli API as something like that: findAny(pattern, pattern, ..., waittime) # comes back when the first one is found findAny(listOfPatterns, waittime) findAll(pattern, pattern, ..., waittime) # comes back after all are found findAll(listOfPatterns, waittime) both come back latest after wait time and return a list of matches corresponding positionally to the given patterns ** Changed in: sikuli Status: New => In Progress ** Changed in: sikuli Assignee: (unassigned) => RaiMan (raimund-hocke) ** Changed in: sikuli Milestone: None => x1.0 -- You received this bug notification because you are a member of Sikuli Drivers, which is subscribed to Sikuli. https://bugs.launchpad.net/bugs/778925 Title: [request] find/findAll to accept list of patterns Status in Sikuli: In Progress Bug description: I wonder if it is possible to create effective algorithm to search for multiple patterns during single scan. I know this is possible for sure if similarity is 1.0. Anyway, it would be nice to have this ability for findAll function, where you need to find a lot of different images in one pass. Using `for image in list_of_patterns: stack += findAll(image)` is very slow. To manage notifications about this bug go to: https://bugs.launchpad.net/sikuli/+bug/778925/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp