Defined Region is getting corrupted if I enter it into a While loop
Hi, I am new to sikuli, so request you all to spoon feed. I am using Sikuli with Eclipse in Java. I am trying to click on a specific region from a while loop. Please find below my problem in detail:-
I have a grid which contains 15 columns and 2 rows. The first row contains the Heading for each of the column and the 2nd row contains corresponding values (which are not fixed; so I can't click on them directly). I have to click on the value field for a specific Column heading and I am doing this by taking the region of the value field by passing the image of the Column heading. I have different functions for getting region of image, clicking on a region by the reference of another image, even for clicking an image.
Now; here's the code I am using to get the region of a specific image. Using this code, I am getting the region of the heading, and the corresponding value.
public static void GetRegionOfImag
try{
Match computerScreenshot = sikuliObj.
int xb = computerScreens
int yb = computerScreens
int wb = computerScreens
int hb = computerScreens
System.
/*Highlighting the result area*/
Region rd=new Region(
rd.highlight(4);
}catch (Exception e) {
e.getMessage();
System.
}
//return rd;
}
Now after getting the Co-ordinate for both the heading as well as the value, I am using the below code to get the region of the value field by passing the image of the heading field.
public static Region GetRegion(String Directory where the Image is kept for Heading,int x,int y,int w,int h) throws Exception {
try{
Match screenShot = sikuliObj.
int x1 = screenShot.x;
int y1 = screenShot.y;
int w1 = screenShot.w;
int h1 = screenShot.h;
System.
/*Highlighting the result area*/
@SuppressWar
Region rd=new Region(
return rd;
}catch (Exception e) {
e.getMessage();
System.
return null;
}
}
Now i am executing the below code from Main() to click on the specified value w.r.t. column heading:-
public static Screen sikuliObj = new Screen();
Region rd10=GetRegion(
rd10.highlight(4);
sikuliObj.
This is clicking the exact region of value. But the trick is:- only 8 out of 15 headings are viewable when I enter into the page for the 1st time. There is an arrow icon just below the grid. If I click on this Icon, the rest of the 7 Headings will be shown one by one. Now, if I need to click on the value corresponding to the 9th or 10th heading (for example), I cannot click it just after I come into the page. I have to click the Arrow icon once or twice and then only I will be able to click on the value corresponding to the 9th or 10th heading. Now I am trying to do this by using a while loop inside Main(). I have kept everything just the same but somehow, sikuli is not clicking the correct region inside while loop. The region is getting corrupted. It is clicking in a completely differnet region everytime. However; I have checked that, it is identifying the root image (Image of the Heading)
ImgStrtWin1= Location for Image of the arrow Icon;
boolean g=true;
while(g)
{
boolean Flag1=IsImagePr
if (Flag1== true) {
/
Region rd10=GetRegion(
rd10.
sikuliObj
System.
g = false;
}
else {
ClickImag
System.
}
}
I have tried this with try-catch also; but no luck.
The functions ClickImage(Image location) and IsImagePresent(
public static void ClickImage(String Directory where image is kept) throws Exception {
Screen Screen2 = new Screen();
try {
if (Screen2.
Screen2.
System.
}
} catch (Exception e) {
e.getMessage();
System.
}
}
public static boolean IsImagePresent(
try{
if(
{
Region rd=sikuliObj.
return true;
}
else
{
return false;
}
}
catch(
{
e.
return false;
}
}
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Sagar Chakraborty for more information if necessary.