Package org.sikuli.api

Examples of org.sikuli.api.DesktopScreenRegion


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

    ScreenRegion s = new DesktopScreenRegion();

    URL imageURL = Images.OSXDockIcon;               
    Target imageTarget = new ImageTarget(imageURL);

    ScreenRegion r = s.find(imageTarget);
    mouse.click(r.getCenter());   

    imageURL = Images.ThumbIcon;               
    imageTarget = new ImageTarget(imageURL);

    r = s.wait(imageTarget, 5000);
    mouse.click(r.getCenter());

    imageURL = Images.CheckedCheckbox;               
    imageTarget = new ImageTarget(imageURL);         

    r = s.wait(imageTarget, 5000);
    mouse.click(r.getCenter());
   
    imageURL = Images.OSXDockIcon;
    imageTarget = new ImageTarget(imageURL);
    r = s.wait(imageTarget, 5000);
   

  }
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);
       
    // create an image target based on an image of a checked checkbox
    ImageTarget checked = new ImageTarget(Images.CheckedCheckbox);
    // create an image target based on an image of an unchecked checkbox
    ImageTarget unchecked = new ImageTarget(Images.UncheckedCheckbox);
   
    // create a multi-state target to look for checkboxes
    MultiStateTarget target = new MultiStateTarget();
    // add the "checked" state specified by the image target of a checked checkbox
    target.addState(checked, "checked");
    // add the "unchecked" state specified by the image target of an unchecked checkbox
    target.addState(unchecked, "unchecked");
       
    // find all the checkboxes, both checked and unchecked
    List<ScreenRegion> checkboxes = s.findAll(target);
    for (ScreenRegion c : checkboxes){
      // get the state of each checkbox
      String state = (String) c.getState();
      // display the state next to each checkbox to visualize
      ScreenLocation labelLocation = Relative.to(c).topLeft().left(70).below(10).getScreenLocation();
View Full Code Here

//    };
   
    ImageExplainer.getExplainer(TextMap.class).setLevel(Level.ALL);
    ImageExplainer.getExplainer(TextTarget.class).setLevel(Level.ALL);
   
    ScreenRegion s = new DesktopScreenRegion();
    String[] stringsToFind = new String[]{
        //"TRANSFER",
        //"DIVIDEND",
        "Account Balance",
        "$4,021.77",
        "$0.30",
        "$3,000.00",
        "$0.25",
        "22296"
    };

    // Find each string and display a box and a text label
    for (String stringToFind : stringsToFind){   
      Target textTarget = new TextTarget(stringToFind);
      ScreenRegion r = s.find(textTarget);
      canvas.addBox(r);
      canvas.addLabel(r, stringToFind);   
    }   
    canvas.display(5);
  }
View Full Code Here

  };

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

    ScreenRegion s = new DesktopScreenRegion()
   
    URL clickhere = SpeakerExample.class.getResource("clickhere.wav");
   
    URL imageURL = Images.GoogleSearchButton;               
    Target imageTarget = new ImageTarget(imageURL);
    ScreenRegion r = s.find(imageTarget);   
    mouse.click(r.getCenter());   
   
    canvas.clear().addBox(r);
    canvas.displayWhile(new SpeakerPlayable(clickhere));

    imageURL = Images.GoogleMicrophoneIcon;               
    imageTarget = new ImageTarget(imageURL);         
    r = s.find(imageTarget);            
    mouse.rightClick(r.getCenter());

    canvas.clear().addBox(r);
    canvas.displayWhile(new SpeakerPlayable(clickhere));

    imageURL = Images.GoogleSearchFeelingLuckyButton;               
    imageTarget = new ImageTarget(imageURL);         
    r = s.find(imageTarget);
    mouse.doubleClick(r.getCenter());

    canvas.clear().addBox(r);
    canvas.displayWhile(new SpeakerPlayable(clickhere));
  }
View Full Code Here

    }
  };

  public static void main(String[] args) {
    simulator.start();   
    ScreenRegion s = new DesktopScreenRegion();     
    URL imageURL = Images.GoogleSearchButton;               
    Target imageTarget = new ImageTarget(imageURL);
    ScreenRegion r = s.find(imageTarget);   
   
    canvas.addBox(Relative.to(r).right(100).getScreenRegion());
    canvas.addLabel(Relative.to(r).right(100).center().getScreenLocation(), "right");

    canvas.addBox(Relative.to(r).left(100).getScreenRegion());
View Full Code Here

import org.sikuli.api.DesktopScreenRegion;

public class DesktopCanvas extends ScreenRegionCanvas {
  public DesktopCanvas() {
    super(new DesktopScreenRegion());
  }
View Full Code Here

    simulator.start();
    ImageExplainer.getExplainer(VisualModelFinder.class).setLevel(Level.STEP);
   
    Rectangle b = simulator.getBounds();
    ScreenRegion s = new DesktopScreenRegion(b.x,b.y,b.width,b.height);

    StyledRectangleTarget target = new StyledRectangleTarget(Images.CalculatorButton);
//    Target target = new StyledRectangleTarget(new URL("file:wally.png"));
//    Target target = new ImageTarget(Images.CalculatorButton);
    target.setLimit(20);
   
    List<ScreenRegion> rs = s.findAll(target);
   
       
    for (ScreenRegion r : rs){
      canvas.addBox(r);
    }
View Full Code Here

  };
 
  public static void main(String[] args) {
    simulator.start();
   
    ScreenRegion s = new DesktopScreenRegion();
    Target imageTarget = new ImageTarget(Images.ThumbIcon);
 
    List<ScreenRegion> rs = s.findAll(imageTarget);
    int no = 1;
    for (ScreenRegion r : rs){
      canvas.addBox(r);
      String labelText = String.format("(%d):%1.3f", no, r.getScore());
      canvas.addLabel(r, labelText);
View Full Code Here

  };

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

    ScreenRegion s = new DesktopScreenRegion();
   
    Target imageTarget = new ImageTarget(Images.ThumbIcon);

    ScreenRegion thumb = s.find(imageTarget);

    ScreenRegionCanvas canvas = new ScreenRegionCanvas(s);
    canvas.addBox(thumb);
    canvas.addLabel(Relative.to(thumb).topLeft().above(20).getScreenLocation(), "ImageTarget:");
    canvas.addImage(Relative.to(thumb).topLeft().above(25).right(85).getScreenLocation(), ImageIO.read(Images.ThumbIcon));
    canvas.display(3);

    Target target = new ImageTarget(Images.UncheckedCheckbox);   
    List<ScreenRegion> checkboxes = s.findAll(target);

    canvas.clear();   
    int no = 1;
    for (ScreenRegion r : checkboxes){     
      String labelText = String.format("(%d):%1.3f", no, r.getScore());
View Full Code Here

    simulator.start();            

    Rectangle b = simulator.getBounds();

    DesktopScreenRegion smallRegion = new DesktopScreenRegion(b.x, b.y, b.width, b.height);

    TargetEventListener l = new TargetEventListener(){              
      @Override
      public void targetAppeared(TargetEvent event) {
        System.out.println(event.getTarget() + " has appeared within " + event.getScreenRegion() +
            " at " + Relative.to(event.getTargetRegion()).topLeft().getScreenLocation())
        canvas.clear().addBox(event.getTargetRegion());
        canvas.addLabel(event.getTargetRegion(),"appeared");
        canvas.display(1);
      }

      @Override
      public void targetVanished(TargetEvent event) {
        System.out.println(event.getTarget() + " has vanished from " + event.getScreenRegion());
        canvas.clear().addBox(event.getTargetRegion());
        canvas.addLabel(event.getTargetRegion(),"vanished");
        canvas.display(1);
      }

      @Override
      public void targetMoved(TargetEvent event) {
        System.out.println(event.getTarget() + " has moved to " +
            Relative.to(event.getTargetRegion()).topLeft().getScreenLocation());
        canvas.clear().addBox(event.getTargetRegion());
        canvas.addLabel(event.getTargetRegion(),"moved");
        canvas.display(1);
      }         
    };

    // watch the dog and the cat in the screen region
    Target cat = new ImageTarget(Images.Cat);
    Target dog = new ImageTarget(Images.Dog);
    smallRegion.addTargetEventListener(dog, l);            
    smallRegion.addTargetEventListener(cat, l);
  }
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.