/** * Move the mouse to this location point and double click left * * @return this */ public Location doubleClick() { Mouse.click(this, "LD"); return this; }
/** * press and hold the specified buttons - use + to combine Button.LEFT left mouse button Button.MIDDLE middle mouse * button Button.RIGHT right mouse button * * @param buttons spec */ public void mouseDown(int buttons) { Mouse.down(buttons, this); }
/** * what to do if mouse is moved outside Sikuli's mouse protection <br> * - Mouse.MouseMovedIgnore (0) ignore it (default) <br> * - Mouse.MouseMovedShow (1) show and ignore it <br> * - Mouse.MouseMovedPause (2) show it and pause until user says continue <br> * (2 not implemented yet - 1 is used) * * @param movedAction value */ public static void setMouseMovedAction(int movedAction) { if (movedAction > -1 && movedAction < 3) { get().device.mouseMovedResponse = movedAction; get().device.mouseMovedCallback = null; log(lvl, "setMouseMovedAction: %d", get().device.mouseMovedResponse); } }
/** * move the mouse from the current position to the offset position given by the parameters * @param xoff horizontal offset (< 0 left, > 0 right) * @param yoff vertical offset (< 0 up, > 0 down) * @return 1 for success, 0 otherwise */ public static int move(int xoff, int yoff) { return move(at().offset(xoff, yoff)); }
/** * move the mouse pointer to the given target location<br> and move the wheel the given steps in the given direction: * <br>Button.WHEEL_DOWN, Button.WHEEL_UP * * @param <PFRML> Pattern, Filename, Text, Region, Match or Location target * @param target Pattern, Filename, Text, Region, Match or Location * @param direction to move the wheel * @param steps the number of steps * @param stepDelay number of miliseconds to wait when incrementing the step value * @return 1 if possible, 0 otherwise * @throws FindFailed if the Find operation failed */ public <PFRML> int wheel(PFRML target, int direction, int steps, int stepDelay) throws FindFailed { Location loc = getLocationFromTarget(target); if (loc != null) { Mouse.use(this); Mouse.keep(this); Mouse.move(loc, this); Mouse.wheel(direction, steps, this, stepDelay); Mouse.let(this); return 1; } return 0; }
/** * current setting what to do if mouse is moved outside Sikuli's mouse protection * * @return current setting see {@link #setMouseMovedAction(int)} */ public static int getMouseMovedResponse() { return get().device.mouseMovedResponse; }
if (get().device.isSuspended() || loc.isOtherScreen()) { return null; getArgsClick(loc, action, args); get().device.use(); Device.delay(mouse.beforeWait); Settings.ClickDelay = mouse.innerWait / 1000; click(loc, mouse.buttons, 0, ((Mouse) get()).clickDouble, null); Device.delay(mouse.afterWait); get().device.let(); return loc;
/** * 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(); }
nMonitor++; Mouse.init(); if (getNumberScreens() > 1) { log(lvl, "initScreens: multi monitor mouse check"); Location lnow = Mouse.at(); float mmd = Settings.MoveMouseDelay; Settings.MoveMouseDelay = 0f; for (Screen s : screens) { lc = s.getCenter(); Mouse.move(lc); lcn = Mouse.at(); if (!lc.equals(lcn)) { log(lvl, "*** multimonitor click check: %s center: (%d, %d) --- NOT OK: (%d, %d)", Mouse.move(lnow); Settings.MoveMouseDelay = mmd;
if (loc == null) { shouldMove = false; loc = at(); return 0; get().device.use(region); profiler.lap("after use"); if (shouldMove) { r.waitForIdle(); profiler.lap("before let"); get().device.let(region); long duration = profiler.end(); Debug.action(getClickMsg(loc, buttons, modifiers, dblClick, duration)); return 1;
/** * @return current location of mouse pointer * @deprecated use {@link Mouse#at()} instead */ @Deprecated public static Location atMouse() { return Mouse.at(); } //</editor-fold>
private static Mouse get() { if (mouse == null) { init(); } return mouse; }
public static void setMouseMovedHighlight(boolean state) { get().device.MouseMovedHighlight = state; }
/** * 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(); }
Match aMatch; if (len == 0 || args[0] == null) { Mouse.move(scr.checkMatch()); return Mouse.at(); try { aMatch = wait(args); Mouse.move(aMatch.getTarget()); } catch (Exception ex) { Mouse.move(scr.checkMatch()); return Mouse.at(); } else if (aObj instanceof Region) { loc = ((Region) aObj).getTarget(); Mouse.move(scr.checkMatch().offset(getInteger(aObj), getInteger(args[1]))); return Mouse.at(); } else if (len == 3 && loc != null && isNumber(args[1]) && isNumber(args[2])) { Mouse.move(loc.offset(getInteger(args[1], 0), getInteger(args[2], 0))); return Mouse.at(); Mouse.move(loc); return Mouse.at(); Mouse.move(scr.checkMatch()); return Mouse.at();
/** * @return current Location * @deprecated use {@link Mouse#at()} instead */ @Deprecated public static Location getMouseLocation() { return Mouse.at(); }
/** * call this, to initialize Sikuli up to useability * * @return the primary screen object or null if headless */ public static Screen init() { if (!canRun()) { return null; } //TODO collect initializations here Mouse.init(); return new Screen(); }