Java Code Examples for org.sikuli.basics.Settings#DelayValue

The following examples show how to use org.sikuli.basics.Settings#DelayValue . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Region.java    From SikuliX1 with MIT License 6 votes vote down vote up
/**
 * finalize a drag action with a drop: move mouse to given target.
 * <br> wait Settings.DelayBeforeDrop before releasing the left mouse button
 *
 * @param <PFRML> Pattern, Filename, Text, Region, Match or Location
 * @param target  Pattern, Filename, Text, Region, Match or Location
 * @return 1 if possible, 0 otherwise
 * @throws FindFailed if not found
 */
public <PFRML> int dropAt(PFRML target) throws FindFailed {
  Location loc = getLocationFromTarget(target);
  int retVal = 0;
  if (loc != null) {
    IRobot r = loc.getRobotForPoint("drag");
    if (r != null) {
      Mouse.use(this);
      r.smoothMove(loc);
      r.delay((int) (Settings.DelayBeforeDrop * 1000));
      r.mouseUp(InputEvent.BUTTON1_MASK);
      r.waitForIdle();
      Mouse.let(this);
      retVal = 1;
    }
  }
  Settings.DelayBeforeMouseDown = Settings.DelayValue;
  Settings.DelayAfterDrag = Settings.DelayValue;
  Settings.DelayBeforeDrag = -Settings.DelayValue;
  Settings.DelayBeforeDrop = Settings.DelayValue;
  return retVal;
}
 
Example 2
Source File: Region.java    From SikuliX1 with MIT License 5 votes vote down vote up
/**
 * Drag from a position and drop to another using left mouse button.
 * <br>applying Settings.DelayAfterDrag and DelayBeforeDrop
 *
 * @param <PFRML> Pattern, Filename, Text, Region, Match or Location
 * @param t1      source position
 * @param t2      destination position
 * @return 1 if possible, 0 otherwise
 * @throws FindFailed if the Find operation failed
 */
public <PFRML> int dragDrop(PFRML t1, PFRML t2) throws FindFailed {
  Location loc1 = getLocationFromTarget(t1);
  Location loc2 = getLocationFromTarget(t2);
  int retVal = 0;
  if (loc1 != null && loc2 != null) {
    IRobot r1 = loc1.getRobotForPoint("drag");
    IRobot r2 = loc2.getRobotForPoint("drop");
    if (r1 != null && r2 != null) {
      Mouse.use(this);
      r1.smoothMove(loc1);
      r1.delay((int) (Settings.DelayBeforeMouseDown * 1000));
      r1.mouseDown(InputEvent.BUTTON1_MASK);
      double DelayBeforeDrag = Settings.DelayBeforeDrag;
      if (DelayBeforeDrag < 0.0) {
        DelayBeforeDrag = Settings.DelayAfterDrag;
      }
      r1.delay((int) (DelayBeforeDrag * 1000));
      r2.smoothMove(loc2);
      r2.delay((int) (Settings.DelayBeforeDrop * 1000));
      r2.mouseUp(InputEvent.BUTTON1_MASK);
      Mouse.let(this);
      retVal = 1;
    }
  }
  Settings.DelayBeforeMouseDown = Settings.DelayValue;
  Settings.DelayAfterDrag = Settings.DelayValue;
  Settings.DelayBeforeDrag = -Settings.DelayValue;
  Settings.DelayBeforeDrop = Settings.DelayValue;
  return retVal;
}
 
Example 3
Source File: Region.java    From SikuliX1 with MIT License 5 votes vote down vote up
/**
 * Prepare a drag action: move mouse to given target.
 * <br>press and hold left mouse button
 * <br>wait Settings.DelayAfterDrag
 *
 * @param <PFRML> Pattern, Filename, Text, Region, Match or Location
 * @param target  Pattern, Filename, Text, Region, Match or Location
 * @return 1 if possible, 0 otherwise
 * @throws FindFailed if not found
 */
public <PFRML> int drag(PFRML target) throws FindFailed {
  Location loc = getLocationFromTarget(target);
  int retVal = 0;
  if (loc != null) {
    IRobot r = loc.getRobotForPoint("drag");
    if (r != null) {
      Mouse.use(this);
      r.smoothMove(loc);
      r.delay((int) (Settings.DelayBeforeMouseDown * 1000));
      r.mouseDown(InputEvent.BUTTON1_MASK);
      double DelayBeforeDrag = Settings.DelayBeforeDrag;
      if (DelayBeforeDrag < 0.0) {
        DelayBeforeDrag = Settings.DelayAfterDrag;
      }
      r.delay((int) (DelayBeforeDrag * 1000));
      r.waitForIdle();
      Mouse.let(this);
      retVal = 1;
    }
  }
  Settings.DelayBeforeMouseDown = Settings.DelayValue;
  Settings.DelayAfterDrag = Settings.DelayValue;
  Settings.DelayBeforeDrag = -Settings.DelayValue;
  Settings.DelayBeforeDrop = Settings.DelayValue;
  return retVal;
}