How to write a while command in java using sikuli script.jar file

Asked by Shivakumar

I trying to use the while command to test, as i used in sikuli IDE it is working.
But in the eclipse the command used is as follows:
while (region.find(pattern).inside().find("C:\\startbutton.png")){

   }
where as the return type of (region.find(pattern).inside().find("C:\\startbutton.png")) is Match type but while support only for boolean, how to use while loop in eclipse for java.

THanks in advance for support...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

As far as I remember, I saw similar topic recently....
There was advised to use region.exists(), not region.find() .
In Sikuli IDE I could use it in code like this:

while not(back_region.exists(back_image)):
                x = random.randint(0,max_x)
                y = random.randint(0,max_y)
                ....

I'm not that familiar with Java, but you can check what region.exists() returns.

Revision history for this message
Shivakumar (shivaselenium) said :
#2

Not only region.exist(), the region.find is working in the sikuli IDE, but it is not working in the eclipse for the lang java....

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

Sikuli IDE is Python language

Your Eclipse code looks like Java.

so you have to use something like:

while (null != region.find(pattern).inside().find("C:\\startbutton.png")) {
}

since java is more strict about conditions. In Python more stuff is accepted as being True and False (it is a scripting language ;-).

Revision history for this message
Shivakumar (shivaselenium) said :
#4

Thanks RaiMan, that solved my question.