本文整理汇总了Java中org.sikuli.api.Target类的典型用法代码示例。如果您正苦于以下问题:Java Target类的具体用法?Java Target怎么用?Java Target使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Target类属于org.sikuli.api包,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interpret
import org.sikuli.api.Target; //导入依赖的package包/类
@Override
protected Action interpret(Slide slide, SlideElement element, String[] arguments){
Long duration;
String durationString = arguments[0];
if (durationString.length() == 0){
duration = Long.MAX_VALUE;
}else{
duration = parseDuration(durationString);
}
if (duration == null)
return null;
Target target = (new ContextImageTargetInterpreter()).interpret(slide);
if (target == null)
return null;
WaitAction action = new WaitAction(target);
action.setDuration(duration);
return action;
}
示例2: createTarget
import org.sikuli.api.Target; //导入依赖的package包/类
Target createTarget(ImageElement imageElement, SlideElement targetElement){
if (imageElement == null || targetElement == null)
return null;
int w = imageElement.getCx();
int h = imageElement.getCy();
if (w <= 0 || h <= 0)
return null;
double xmax = 1.0 * (targetElement.getOffx() + targetElement.getCx() - imageElement.getOffx()) / w;
double ymax = 1.0 * (targetElement.getOffy() + targetElement.getCy() - imageElement.getOffy()) / h;
double xmin = 1.0 * (targetElement.getOffx() - imageElement.getOffx()) / w;
double ymin = 1.0 * (targetElement.getOffy() - imageElement.getOffy()) / h;
xmax = Math.min(1.0, xmax);
ymax = Math.min(1.0, ymax);
xmin = Math.max(0, xmin);
ymin = Math.max(0, ymin);
return new ContextImageTarget(imageElement.getSource(), xmin, ymin, xmax, ymax);
}
示例3: testHypotheses
import org.sikuli.api.Target; //导入依赖的package包/类
static private ScreenRegion testHypotheses(ScreenRegion screenRegion, List<Hypothesis> hypotheses){
for(Hypothesis hypothesis : hypotheses){
Target target = hypothesis.getTarget();
target.setMinScore(0.8f);
List<ScreenRegion> lookupRegion = screenRegion.findAll(target);
logger.trace("test: {} ... found {} matches", hypothesis, lookupRegion.size());
if(lookupRegion.size()>1){
continue;
}
else if(lookupRegion.size()==1){
ScreenRegion rawResult = lookupRegion.get(0);
return hypothesis.interpretResult(rawResult);
}else {
return null;
}
}
return null;
}
示例4: findElement
import org.sikuli.api.Target; //导入依赖的package包/类
@Override
public Widget findElement(String label) {
Widget element = spec.findElementByLabel(label);
if (element == null)
// element of the given label does not exist
return null;
log.debug("attempt to find: "+ element);
Target target = element.getTarget();
ScreenRegion screen = getScreenRegion();
ScreenRegion found = screen.find(target);
if (found != null){
log.debug("target is found at: " + found);
element.setScreenRegion(found);
}else{
log.debug("target is not found!");
}
return element;
}
示例5: testCanStopEarlierBeforeTimeout
import org.sikuli.api.Target; //导入依赖的package包/类
@Test(timeout = 5000)
public void testCanStopEarlierBeforeTimeout() throws ActionExecutionException {
Target target = MockTargetFactory.canBeFoundAfter(10000);
final WaitAction action = new WaitAction(target);
action.setDuration(10000);
new Thread(){
public void run(){
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
action.stop();
}
}.start();
action.execute(context);
}
示例6: testCanDistinguishAmbiguousInputFields
import org.sikuli.api.Target; //导入依赖的package包/类
@Test
public void testCanDistinguishAmbiguousInputFields() throws IOException{
ScreenRegion screenRegion = new StaticImageScreenRegion(ImageIO.read(login));
// the target is an input field, the whole image has two input fields
// the label above is distinctive
Target target = new ContextImageTarget(login, 59, 145, 80, 50);
List<ScreenRegion> list = target.doFindAll(screenRegion);
// should return only one, instead of two
assertThat(list.size(), equalTo(1));
ScreenRegion r = list.get(0);
assertThat(r.getBounds().x, equalTo(59));
assertThat(r.getBounds().y, equalTo(145));
}
示例7: getTarget
import org.sikuli.api.Target; //导入依赖的package包/类
@Override
public Target getTarget(){
Rectangle r = contextTargetRect;
BufferedImage targetImage = contextImage.getSubimage(r.x,r.y,r.width,r.height);
Target target = new ImageTarget(targetImage);
return target;
}
示例8: step1
import org.sikuli.api.Target; //导入依赖的package包/类
public boolean step1() {
Target target = new ImageTarget(new File("image1.png"));
target.setMinScore(DEFAULT_MINSCORE);
ScreenRegion loc = screenRegion.find(target);
if (loc != null){
mouse.click(loc.getCenter());
return true;
}else{
return false;
}
}
示例9: step2
import org.sikuli.api.Target; //导入依赖的package包/类
public boolean step2() {
Target target = new ImageTarget(new File("image2.png"));
target.setMinScore(DEFAULT_MINSCORE);
ScreenRegion loc = screenRegion.find(target);
if (loc != null){
mouse.rightClick(loc.getCenter());
return true;
}else{
return false;
}
}
示例10: step3
import org.sikuli.api.Target; //导入依赖的package包/类
public boolean step3() {
Target target = new ImageTarget(new File("image3.png"));
target.setMinScore(DEFAULT_MINSCORE);
ScreenRegion loc = screenRegion.find(target);
if (loc != null){
mouse.click(loc.getCenter());
keyboard.type("something to type");
return true;
}else{
return false;
}
}
示例11: step5
import org.sikuli.api.Target; //导入依赖的package包/类
public boolean step5() {
Target target = new ImageTarget(new File("image5.png"));
target.setMinScore(DEFAULT_MINSCORE);
ScreenRegion loc = screenRegion.find(target);
return loc != null;
}
示例12: step7
import org.sikuli.api.Target; //导入依赖的package包/类
public boolean step7() {
Target target = new ImageTarget(new File("image7.png"));
target.setMinScore(DEFAULT_MINSCORE);
ScreenRegion loc = screenRegion.find(target);
if (loc != null){
mouse.click(loc.getCenter());
keyboard.type("something to type");
return true;
}else{
return false;
}
}
示例13: interpret
import org.sikuli.api.Target; //导入依赖的package包/类
@Override
public SlideSpec interpret(Slide slide) {
SlideSpec page = new SlideSpec();
// find all targets
List<SlideElement> targetElements = slide.select().isTarget().all();
// for each target element, create a context target
for (SlideElement targetElement : targetElements){
ImageElement imageElement = (ImageElement) slide.select().intersects(targetElement).isImage().first();
if (imageElement == null)
continue;
Target target = interpret(slide, targetElement);
if (target == null)
continue;
SlideElement labelElement = slide.select().intersects(targetElement).hasText().first();
if (labelElement == null)
continue;
DefaultWidget element = new DefaultWidget(target, labelElement.getText());
page.add(element);
log.trace("added to spec: " + element);
}
return page;
}
示例14: ContextImageTarget
import org.sikuli.api.Target; //导入依赖的package包/类
@Test
public void ContextImageTarget(){
Slide slide = new Slide();
on(slide).insert().image().source(TestResources.get("sikuli_context.png")).bounds(100,100,1000,1000);
on(slide).insert().element().bounds(348,223,200,200);
TargetInterpreter interpreter = new DefaultInterpreter.ContextImageTargetInterpreter();
Target target = interpreter.interpret(slide);
assertThat(target, instanceOf(ContextImageTarget.class));
}
示例15: testCanThrowExceptionWhenTargetDoesNotAppearsAfter2Seconds
import org.sikuli.api.Target; //导入依赖的package包/类
@Test(timeout = 2500, expected = ActionExecutionException.class)
public void testCanThrowExceptionWhenTargetDoesNotAppearsAfter2Seconds() throws ActionExecutionException {
Target target = MockTargetFactory.canBeFoundAfter(3000);
WaitAction action = new WaitAction(target);
action.setDuration(1000);
action.execute(context);
}