/** * same as use(), but only affects the next processed undotted function * after that the use() active before is restored * * @param args see use() * @return the used region */ public static Region use1(Object... args) { logCmd("use1", args); scrSaved = scr; return usex(args); }
/** * move the mouse to the given location with a given offset<br> * 3 parameter configurations:<br> * --1: wait for a visual and move mouse to it (args see wait())<br> * --2: move to the given region/location/match with a given offset<br> * --3: move to the given offset relative to the last match of the region in use * * @param args * @return the evaluated location to where the mouse should have moved */ public static Location hover(Object... args) { logCmd("hover", args); return hoverx(args); }
/** * all following undotted function calls will use the given screen or region * until this is changed by a later use()<br> * -- no args: use Screen(0) (this is the default after start)<br> * -- a number: use Screen(number), Screen(0) if not valid<br> * -- a region: use the given region<br> * * @param args * @return the used region */ public static Region use(Object... args) { logCmd("use", args); scrSaved = null; return usex(args); }
/** * just doing a currentRegion.paste(text) (see paste()) * * @param args only one parameter being a String * @return true if paste() returned 1, false otherwise */ public static boolean paste(Object... args) { logCmd("paste", args); Object[] realArgs = typeArgs(args); return 0 < scr.paste((String) realArgs[0]); }
/** * just doing a currentRegion.write(text) (see write()) * * @param args only one parameter being a String * @return true if write() returned 1, false otherwise */ public static boolean write(Object... args) { logCmd("write", args); Object[] realArgs = typeArgs(args); return 0 < scr.write((String) realArgs[0]); }
/** * wait for the given visual to appear within the given wait time<br> * args [String|Pattern|Double, [Double, [Float]]] (max 3 args)<br> * arg1: String/Pattern to search or double time to wait (rest ignored)<br> * arg2: time to wait in seconds<br> * arg3: minimum similarity to use for search (overwrites Pattern setting)<br> * * @param args * @return the match or throws FindFailed * @throws FindFailed */ public static Match wait(Object... args) throws FindFailed { logCmd("wait", args); Object[] realArgs = waitArgs(args); return waitx((String) realArgs[0], (Pattern) realArgs[1], (Double) realArgs[2], (Float) realArgs[3]); }
/** * wait for the given visual to appear within the given wait time * * @param args see wait() * @return the match or null if not found within wait time (no FindFailed exception) */ public static Match exists(Object... args) { logCmd("exists", args); Match match = null; Object[] realArgs = waitArgs(args); if ((Double) realArgs[2] < 0.0) { realArgs[2] = 0.0; } try { match = waitx((String) realArgs[0], (Pattern) realArgs[1], (Double) realArgs[2], (Float) realArgs[3]); } catch (Exception ex) { return null; } return match; } //</editor-fold>
/** * move the mouse with hover() and double click using the left button * * @param args see hover() * @return the location, where the double click was done */ public static Location doubleClick(Object... args) { logCmd("doubleClick", args); Location loc = hoverx(args); Mouse.click(null, Button.LEFT, 0, true, null); return Mouse.at(); }
/** * move the mouse with hover() and do a right click * * @param args see hover() * @return the location, where the right click was done */ public static Location rightClick(Object... args) { logCmd("rightClick", args); Location loc = hoverx(args); Mouse.click(null, Button.RIGHT, 0, false, null); return Mouse.at(); } //</editor-fold>
/** * move the mouse with hover() and click using the left button * * @param args see hover() * @return the location, where the click was done */ public static Location click(Object... args) { logCmd("click", args); Location loc = hoverx(args); Mouse.click(null, Button.LEFT, 0, false, null); return Mouse.at(); }
/** * 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); }