Package org.sikuli.api.robot

Examples of org.sikuli.api.robot.Mouse


import org.sikuli.api.visual.ScreenRegionCanvas;

public class MultiScreenExample {

  public static void main(String[] args) throws IOException  {
    Mouse mouse = new DesktopMouse();
   
    // 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);
      c.addLabel(innerRegion.getCenter(), "Screen " + screenId).withFontSize(30);
      c.addImage(Relative.to(innerRegion).center().above(200).getScreenLocation(), ImageIO.read(Images.Dog));
      c.show();
     
      // hover the mouse cursor to each corner of the inner circle
      mouse.hover(Relative.to(innerRegion).topLeft().getScreenLocation());
      mouse.hover(Relative.to(innerRegion).topRight().getScreenLocation());
      mouse.hover(Relative.to(innerRegion).bottomRight().getScreenLocation());
      mouse.hover(Relative.to(innerRegion).bottomLeft().getScreenLocation());
     
      // find the dog and click on it
      ScreenRegion dog = innerRegion.find(new ImageTarget(Images.Dog));
      mouse.click(dog.getCenter());
     
      c.hide();
    }
   
 
View Full Code Here


    // Display "Hello World" next to the found target for 3 seconds
    Canvas canvas = new DesktopCanvas();
    canvas.addLabel(r, "Hello World").display(3);
   
    // Click the center of the found target
    Mouse mouse = new DesktopMouse();
    mouse.click(r.getCenter());
  }
View Full Code Here

       
    DragDropFrame imageFrame = new DragDropFrame(backgroundImage,dragTargetImage);
    imageFrame.autoClose(10000);
   
    ScreenRegion s = new DesktopScreenRegion();   
    Mouse mouse = new DesktopMouse();

    URL imageURL = Images.OSXDockIcon;               
    Target imageTarget = new ImageTarget(imageURL);
   
    ScreenRegion r = s.wait(imageTarget,1000);
    mouse.drag(r.getCenter());
   
   
    imageURL = Images.GoogleMicrophoneIcon;               
    imageTarget = new ImageTarget(imageURL);
   
    r = s.wait(imageTarget,1000);
    mouse.drop(r.getCenter());
   
   
    ScreenLocation c = mouse.getLocation();   
    mouse.drag(c);
    mouse.drop(Relative.to(c).left(200).above(50).getScreenLocation());

  }   
View Full Code Here

TOP

Related Classes of org.sikuli.api.robot.Mouse

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.