Package org.sikuli.api

Examples of org.sikuli.api.DesktopScreenRegion


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

    // Obtain the screen region object corresponding to the
    // default monitor in full screen
    ScreenRegion s = new DesktopScreenRegion()
   
    // Define an image target on the screen
    URL imageURL = Images.GoogleSearchButton;               
    Target imageTarget = new ImageTarget(imageURL);
    // Issue the find command and get a new screen region
    // 'r' corresponding to the screen region occupied
    // by the found target
    ScreenRegion r = s.find(imageTarget);   
    // Click the center of 'r'   
    mouse.click(r.getCenter());   
    // Display a box around 'r' for 1 second
    canvas.addBox(r).display(1);

    // Find another image target and perform similar operations
    imageURL = Images.GoogleMicrophoneIcon;               
    imageTarget = new ImageTarget(imageURL);         
    r = s.find(imageTarget);            
    mouse.rightClick(r.getCenter());
    canvas.clear().addBox(r).display(1);

    // Find another image target and perform similar operations
    imageURL = Images.GoogleSearchFeelingLuckyButton;               
    imageTarget = new ImageTarget(imageURL);         
    r = s.find(imageTarget);
    mouse.doubleClick(r.getCenter());
    canvas.clear().addBox(r).display(1);

  }
View Full Code Here


    MyScreen myScreen = new MyScreen(f);
    MyMouse myMouse = new MyMouse(f);
    MyPainter myPainter = new MyPainter(f);

    ScreenRegion s = new DesktopScreenRegion();
    s.setScreen(myScreen);

    for (int i=0; i < 10; i++){

      f.moveButtonsRandomly();

      ScreenRegion dogRegion = s.find(new ImageTarget(Images.Dog));
      ScreenRegion catRegion = s.find(new ImageTarget(Images.Cat));

      myMouse.click(dogRegion.getCenter());
      myMouse.click(catRegion.getCenter());

      myPainter.rectangle(dogRegion);
View Full Code Here

  public static void main(String[] args) throws MalformedURLException {
   
    browse(new URL("http://www.twitter.com/search"));

    ScreenRegion s = new DesktopScreenRegion();
       
    Target searchButtonImageTarget = new ImageTarget(Images.TwitterSearchButton);
       
    ScreenRegion searchButton = s.wait(searchButtonImageTarget, 5000);
   
    // Pause one second to allow search results to load
    pause(1000);       
   
    keyboard.type("sikuli");
   
    ScreenLocation outside = Relative.to(searchButton).right(50).center().getScreenLocation();
    mouse.click(outside);
       
    mouse.click(searchButton.getCenter());
   
    // Pause one second to allow search results to load
    pause(1000);
         
    // Scroll-down until the "View All Tweets Link" becomes visible
    Target viwAllTweetsLinkImageTarget = new ImageTarget(Images.TwitterViewAllTweetsLink);
    while (s.find(viwAllTweetsLinkImageTarget) == null) {
      keyboard.type(Key.PAGE_DOWN);         
    }
   
    // Find and click on the link
    ScreenRegion viwAllTweetsLink = s.find(viwAllTweetsLinkImageTarget);
    mouse.click(viwAllTweetsLink.getCenter());
     
  }
View Full Code Here

   
    simulator.start();
   
    Rectangle b = simulator.getBounds();

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

    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() + "}");           
      }         
    };


    Target cat = new ImageTarget(Images.Cat);
    Target dog = new ImageTarget(Images.Dog);

    smallRegion.addState(cat, "HAS A CAT");
    smallRegion.addState(dog, "HAS A DOG");
    smallRegion.addStateChangeEventListener(l);

    // TODO: test if remove works
    //smallRegion.removeState(cat);

    canvas.addBox(smallRegion).display(10);
View Full Code Here

    f2.pack();   
    f2.setVisible(true);
    f2.setLocation(600,20);
    f2.setTitle("MyApp 2");

    ScreenRegion s1 = new DesktopScreenRegion();
    s1.setScreen(f1);

    ScreenRegion s2 = new DesktopScreenRegion();
    s2.setScreen(f2);

    for (int i=0; i < 10; i++){
     
      f1.moveButtonsRandomly();
      f2.moveButtonsRandomly();

      ScreenRegion dogRegion = s1.find(new ImageTarget(Images.Dog));
      ScreenRegion catRegion = s2.find(new ImageTarget(Images.Cat));
           
      MyApp.click(dogRegion.getCenter());
      MyApp.click(catRegion.getCenter());
     
      MyApp.rectangle(dogRegion);
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.