Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get image location with Sikuli using Java?

It's very hard to find Sikuli examples for Java, all is written for Python or Sikuli IDE. I have defined a pattern that I'm able to click on, hover etc..

How can I save its coordinates into a variable so I'll be able to use it later for navigation?

like image 735
Dotan Raz Avatar asked Mar 22 '26 03:03

Dotan Raz


1 Answers

I don't know what you mean when you say "pattern". Do you refer to the actual Sikuli Pattern class? Or just use it as general word? Anyway, you can store the coordinates of a pattern found on the screen like this:

Region reg = new Screen();
Pattern p = new Pattern("someImage.png");
Match m = reg.find(p);

Then you can either access the coordinates directly as they all defined using public access level modifiers:

int x = m.x;
int y = m.y;

Or you can use the getter methods available through the same class:

int x = m.getX();
int y = m.getY();

Alternatively, you can store the whole Location object for your future reference:

Location l = m.getTarget();

int x = l.x;
int y = l.y;

int x = l.getX();
int y = l.getY();
like image 119
Eugene S Avatar answered Mar 23 '26 17:03

Eugene S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!