← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #667091]: Click on random places

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Retina
upgrade to 1.1.2 and use the SikuliX IDE to shoot your images

--- handling of the images:
- save a script as "/Users/goldgames/Documents/SikuliX/ScreenShots.sikuli"
- shoot your images using a naming convention
- take care, that the script is saved, before trying to use the images in Java

in Java add once:
ImagePath.add("/Users/goldgames/Documents/SikuliX/ScreenShots.sikuli")

and reference your images this way:
Pattern p = new Pattern("aaa"); // for .png the ending can be omitted
BTW: Pattern is only needed if you want to set a similarity or a targetOffset

so for a simple image:
screen.wait("aaa",2).click()

you might want to handle FindFailed situations with try{}catch(){}

So if it clicks something once, then it has found something similar to the given image.
look at the match:

Match m = screen.wait("aaa",2);
m.click() // just put a debug breakpoint here 

--- import java.awt.event.KeyEvent;
... does not make sense in a Java program using SikuliX features

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