sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #44201
[Question #659989]: How to properly use observe to track region changes
New question #659989 on Sikuli:
https://answers.launchpad.net/sikuli/+question/659989
This question pertains to the SikuliX 1.1.1 Java API.
I am trying to figure out how to track a region I have defined.
Specifically, my region encapsulates a character on the screen. I want to observe when he stops moving.
When he stops moving, I want to call a different function.
I believe I should use observe() and track onChange(), which will tell me when the character is moving. And when
onChange() reports false, it will tell me my character has stopped.
But I cannot seem to figure out how to get the onChange results()
to evaluate when he's moving and when he's not. I am not setting up the
observe functionality correctly.
This is what I have so far:
public void targetChanged(SikuliEvent e){
Region x = e.getRegion();
System.out.println(x);
}
public static void main(String[] args){
Screen s = new Screen();
Region r = new Region(s.getBounds());
Location l = r.getCenter();
Region characterRegion = new Region(l.x, l.y, 30, 40).offset(new Location(-30/2, -40/2));
characterRegion.onChange();
characterRegion.observe(1);
}
Currently the program just terminates.
What do I need to change to get my desired functionality?
I'm having trouble figuring out the documentation.
Detailed advice, explanations, and examples are appreciated.
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.