Reputation: 453
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?
Upvotes: 3
Views: 4136
Reputation: 6910
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();
Upvotes: 4