Package org.sikuli.api

Examples of org.sikuli.api.DesktopScreenRegion


  public static void main(String[] args) {
    simulator.start();

    Rectangle b = simulator.getBounds();
    ScreenRegion s = new DesktopScreenRegion(b.x,b.y,b.width,b.height);
   
    ScreenRegion icon1 = s.find(new ImageTarget(Images.PersonIcon));;
    ScreenRegion icon2 = s.find(new ImageTarget(Images.ThumbIcon));;
    ScreenRegion icon3 = s.find(new ImageTarget(Images.TwitterBirdIcon));;

    canvas.addBox(icon1);
    canvas.addBox(icon2);
    canvas.addBox(icon3);
    canvas.display(1);
View Full Code Here


 
    simulator.setSize(800,800);
    simulator.start();
   
    Rectangle b = simulator.getBounds();
    ScreenRegion s = new DesktopScreenRegion(b.x,b.y,b.width,b.height)

    Target target;
    List<ScreenRegion> rs;

    // find all unchecked checkboxes ordered from bottom to top 
   
    target = new ImageTarget(Images.UncheckedCheckbox);
    target.setLimit(15);
    target.setOrdering(Target.Ordering.BOTTOM_UP);
   
    rs = s.findAll(target);
   
    canvas.addLabel(Relative.to(s).topLeft().getScreenLocation(), "Unchecked checkboxes found in bottom-up ordering");
    for (int i=0; i < rs.size(); ++i){
      ScreenRegion r = rs.get(i);
      canvas.addBox(r);
      canvas.addLabel(Relative.to(r).topLeft().left(20).getScreenLocation(), ""+(i+1));
    }
    canvas.display(5);
       
    // find all styled rectangles (e.g., buttons) ordered from left to right
 
    target = new StyledRectangleTarget(Images.ButtonOptions);
    target.setOrdering(Target.Ordering.LEFT_RIGHT);
   
    rs = s.findAll(target);
   
    canvas.clear().addLabel(Relative.to(s).topLeft().getScreenLocation(), "Rectangles found in left-right ordering");
    for (int i=0; i < rs.size(); ++i){
      ScreenRegion r = rs.get(i);
      canvas.addBox(r);
View Full Code Here

 
 
  public static void main(String[] args) {
    simulator.start();   
    Rectangle b = simulator.getBounds();
    ScreenRegion s = new DesktopScreenRegion(b.x+10,b.y+30,b.width-20,b.height-40)
   
    canvas.addBox(s);
    canvas.addLabel(Relative.to(s).topLeft().getScreenLocation(), "Observed region");
    canvas.display(2);
   
    Target target = new ForegroundTarget();
    ScreenRegion r = s.find(target);   
   
    canvas.clear();
    canvas.addBox(r);
    canvas.addLabel(Relative.to(s).topLeft().getScreenLocation(), "find");
    canvas.addLabel(Relative.to(r).topLeft().getScreenLocation(), "foreground object");
    canvas.display(2);
   
    List<ScreenRegion> rs = s.findAll(target);
    canvas.clear();
    canvas.addLabel(Relative.to(s).topLeft().getScreenLocation(), "findAll");
    for (ScreenRegion x : rs){     
      canvas.addBox(x);
      canvas.addLabel(Relative.to(x).topLeft().getScreenLocation(), "foreground object");
View Full Code Here

   
    simulator.start();

    Rectangle b = simulator.getBounds();
   
    ScreenRegion s = new DesktopScreenRegion(b.x, b.y, b.width, b.height);
    canvas.addBox(s).display(2);               

    StateChangeListener l = new StateChangeListener(){              

      @Override
      public void stateChanged(StateChangeEvent event) {
        System.out.println(event.getScreenRegion() + "'s state is changed " +
            "from {" + event.getOldState() + "} " +
            " to {" + event.getNewState() + "}");     
       
       
        String txt = event.getOldState() + "->" + event.getNewState();
        ScreenLocation labelLocation = Relative.to(event.getScreenRegion()).topLeft().above(20).getScreenLocation();
        canvas.clear().addLabel(labelLocation,txt).display(1);
      }         
    };

    ScreenRegion personIcon = s.wait(new ImageTarget(Images.PersonIcon),1000);   
    canvas.clear().addBox(personIcon).display(1);
   
    ScreenRegion statusIcon = Relative.to(personIcon).right(30).getScreenRegion();
    canvas.clear().addBox(personIcon).display(1);   
View Full Code Here

 
  public static void main(String[] args) {
   
    simulator.start();            
    Rectangle b = simulator.getBounds();
    ScreenRegion s = new DesktopScreenRegion(b.x, b.y, b.width, b.height);

    List<ScreenRegion> rs;
    Target target = new ImageTarget(Images.HollowRedStar);
    target.setOrdering(Ordering.LEFT_RIGHT);
    rs = s.findAll(target);         

    ScreenRegion left = rs.get(0);
    ScreenRegion right = rs.get(1);

    left = Relative.to(left).taller(30).wider(30).getScreenRegion();
View Full Code Here

    simulator.start();
       
    Rectangle b = simulator.getBounds();
   
    final DesktopScreenRegion s = new DesktopScreenRegion(b.x, b.y, b.width, b.height);


    // Finding color stars

    Target blueTarget = new ColorImageTarget(Images.BlueStar);
    Target redTarget = new ColorImageTarget(Images.RedStar);
    Target greenTarget = new ColorImageTarget(Images.GreenStar);

    List<ScreenRegion> blueTargetRegions = s.findAll(blueTarget);
    List<ScreenRegion> greenTargetRegions = s.findAll(greenTarget);
    List<ScreenRegion> redTargetRegions = s.findAll(redTarget);
   
    for (ScreenRegion r : blueTargetRegions){
      canvas.addBox(r);
      canvas.addLabel(r, "blue");     
    }

    for (ScreenRegion r : redTargetRegions){
      canvas.addBox(r);
      canvas.addLabel(r, "red");     
    }

    for (ScreenRegion r : greenTargetRegions){
      canvas.addBox(r);
      canvas.addLabel(r, "green");     
    }
    canvas.display(3);
   
    simulator.resume();
   
    canvas.clear();
   
    // Finding color bullets
    ScreenRegion greenBullet = s.wait(new ColorImageTarget(Images.GreenBullet),10000);
    ScreenRegion redBullet = s.find(new ColorImageTarget(Images.RedBullet));
    ScreenRegion silverBullet = s.find(new ColorImageTarget(Images.SilverBullet));
   
    canvas.addBox(greenBullet);   
    canvas.addLabel(Relative.to(greenBullet).topLeft().above(20).getScreenLocation(), "green");
   
    canvas.addBox(redBullet);
View Full Code Here

  static Mouse mouse = new DesktopMouse();
  static Keyboard keyboard = new DesktopKeyboard();
  static Canvas canvas = new DesktopCanvas();

  public static void main(String[] args) throws IOException {
    DesktopScreenRegion smallRegion = new DesktopScreenRegion(500,500,400,200);
    canvas.addBox(smallRegion).display(1);
   
    BufferedImage capturedImage = smallRegion.capture();
    ImageIO.write(capturedImage, "png", new File("SavedCaptuedImage.png"));
  }
View Full Code Here

    // iterate through each screen, the mouse cursor will traverse along the edges
    // of a rectangle centered on each screen clockwise, and then clicks on the dog image
    int numOfScreens = DesktopScreen.getNumberScreens();
    for (int screenId = 0; screenId < numOfScreens; screenId++){
     
      ScreenRegion screenRegion = new DesktopScreenRegion(screenId);
      ScreenRegion innerRegion = Relative.to(screenRegion).shorter(100).narrower(100).getScreenRegion();

      // create a canvas to draw visualization on the screen
      Canvas c = new ScreenRegionCanvas(screenRegion);
      c.addBox(innerRegion);
View Full Code Here

  public static void main(String[] args) {
   
    simulator.start();
   
    Rectangle b = simulator.getBounds();
    DesktopScreenRegion s = new DesktopScreenRegion(b.x,b.y,b.width,b.height)
    canvas.addBox(s).display(5);
    //s.record(new File("ScreenRegionRecordExampleVideo.mov"), 5000);
   
  }
View Full Code Here


  public static void main(String[] args) {
    simulator.start();

    ScreenRegion s = new DesktopScreenRegion()

    ScreenRegion dog = s.find(new ImageTarget(Images.Dog));
    ScreenRegion cat = s.find(new ImageTarget(Images.Cat));
   
    mouse.click(dog.getCenter());
    mouse.click(cat.getCenter());

    mouse.rightClick(dog.getCenter());
View Full Code Here

TOP

Related Classes of org.sikuli.api.DesktopScreenRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.