I have a small head scratching puzzle. It's beyond my noob skills at the moment.
The goal of this script is to search the screen for image1.bmp and click on image1.bmp every time its found on the screen until it finds image2.bmp then the script should exit the mainloop and find image2.bmp then click on it to exit the script.
Something so simple is causing me hair-loss. Because it exits after click on image1.bmp
Logic flow:
The following code loop looks for image2.bmp
If doesn't find image2.bmp then it looks for image1.bmp
If it finds image1.bmp then it clicks on it
the Numfound variable is reset to 0 returns to the main loop.
If it finds image2.bmp then it jumps to FinishUp clicks image2.bmp
then script stops.
The Puzzle:
From the coding, it should not exit the script unless it finds image2.bmp & clicks on it.
What's happening is the script will exit after it finds image1.bmp and clicks it.
After debugging, i can't find out why this is happening.
The only value would be the NumFound is greater than zero, however debugging shows the value is reset to zero after it clicks image1.bmp and the script stops.
The Question: Why? What am I missing? Is there a better/more reliable approach?
Code: Select all
Label>MainLoop
Let>NumFound=0
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Goto>FinishUp
Else
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Let>NumFound=0
Endif
Endif
Wait 2
Goto>MainLoop
Label>FinishUp
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
//Eject from script