/** * Pattern from file. * * @param path - image file path * @param similarity - similarity fraction * @return Pattern created from image */ public static Pattern pattern(String path, float similarity) { return pattern(path).similar(similarity); }
private static Match waitx(String image, Pattern pimage, double timeout, float score) throws FindFailed { Object aPattern = null; if (image != null) { if (score > 0) { aPattern = new Pattern(image).similar(score); } else { aPattern = image; } } else if (pimage != null) { aPattern = pimage; } if (aPattern != null) { if (timeout > -1.0) { return scr.wait(aPattern, timeout); } return scr.wait(aPattern); } return null; }
/** * wait for the given visual to vanish within the given wait time * * @param args see wait() * @return true if not there from beginning or vanished within wait time, false otherwise */ public static boolean waitVanish(Object... args) { logCmd("waitVanish", args); Object aPattern; Object[] realArgs = waitArgs(args); String image = (String) realArgs[0]; Pattern pimage = (Pattern) realArgs[1]; double timeout = (Double) realArgs[2]; float score = (Float) realArgs[3]; if (image != null) { if (score > 0) { aPattern = new Pattern(image).similar(score); } else { aPattern = image; } } else { aPattern = pimage; } if (timeout > -1.0) { return scr.waitVanish(aPattern, timeout); } return scr.waitVanish(aPattern); }
} else if ("P".equals(oType)) { newObj = new Pattern(json[1]); ((Pattern) newObj).similar(fltFromJSON(json, 2)); ((Pattern) newObj).targetOffset(intFromJSON(json, 3), intFromJSON(json, 4));
lastSearchTime = (new Date()).getTime(); Finder f = new Finder(new Screen().capture(r), r); f.find(new Pattern(img).similar(Settings.CheckLastSeenSimilar)); if (f.hasNext()) { log(lvl + 1, "checkLastSeen: still there");