Question #453545 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/453545

Description changed to:
Hello ,I have some question of coding siklui in Java.
Question1 :
 I want let sikuli to find a image location,and click it randomly.
My code is works for me ,but my code seems can be more easier .

Here is my code01:
----------------------------------------------------------
class Randomcb  {
        Screen s = new Screen();
        Region reg = new Screen();
        Random ran = new Random();
        private int Rx,Ry,Rh,Rw,fx,fy;
        public void RndClik(String Path)
        {
        Rx = reg.exists(Path).getX();
    Ry = reg.exists(Path).getY();
    Rh = reg.exists(Path).getH();
    Rw = reg.exists(Path).getW();
    
        fx=Rx+ran.nextInt(Rw);
        fy=Ry+ran.nextInt(Rh);
        Location Lr =new Location(fx,fy);
          
    try{ s.click(Lr);}
    catch(FindFailed e){e.printStackTrace();}
    }
----------------------------------------------------------
And I can call by folowing:

Randomcb randomcb= new Randomcb();
randomcb.RndClik("image path");


Question2 :
I want just move mouse to a location by coordinate.
The same ,this code works for me,but when I just feel something wrong.
Maybe sikuli already has some way to do this?

Here is my code02
----------------------------------------------------------
public void MouseMoveTo(int bx,int by)
        {    
                Region reg = new Screen();
                reg.x=bx;
                reg.y=by;
                Location  Lr2= new Location(reg.x, reg.y);
                 try{reg.mouseMove(Lr2);}
                 catch(FindFailed e){e.printStackTrace();}              
        }
----------------------------------------------------------

Thank you for your reading

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to