Good afternoon, I have the script below, I want to locate an image on the screen and click on it, if I don't find it it gives an image not found message, but in any case the image is not found, even though it is on the screen.
I've tested with exact coefficient or 0.7, I've tested with Image Recognition Wizard too, but then it always executes the code, whether or not it locates the image. Can anyone help me? Thanks
Label>Inicio
Let>WSI_TIMEOUT=3
WaitScreenImage>C:\Users\User\OneDrive\Documentos\Macro Scheduler 15\Samples\MMV_Ajuda_Amigos_Larva\image_1.bmp,10,EXACT
MessageModal>VALOR DE WSI_TIMEOUT É %WSI_RESULT%
If>WSI_TIMEOUT=FALSE
//Find and Left Click Center of
FindImagePos>C:\Users\User\OneDrive\Documentos\Macro Scheduler 15\Samples\MMV_Ajuda_Amigos_Larva\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
Message>ENCONTROU E CLICOU NO REGADOR GRANDE
LClick
Endif
Else
Message>NAO ENCONTROU REGADOR GRANDE
Endif
Goto>Inicio
Marcus
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Marcus
It took me quite a while to spot this, as it's an easy mistake to make.
This:
Should be this :
TIMEDOUT, not TIMEOUT
WaitScreenImage : The system variable WSI_TIMEOUT can be used to set the number of seconds after which this command should timeout. If set to zero (the default) the timeout will not occur and the command will continue indefinitely. If WSI_TIMEOUT is used, WSI_TIMEDOUT will indicate whether or not the command ended successfully. If it timed out WSI_TIMEDOUT will be set to TRUE otherwise, if the image was found within the time out period it will be set to FALSE
This:
Code: Select all
If>WSI_TIMEOUT=FALSE
Code: Select all
If>WSI_TIMEDOUT=FALSE
WaitScreenImage : The system variable WSI_TIMEOUT can be used to set the number of seconds after which this command should timeout. If set to zero (the default) the timeout will not occur and the command will continue indefinitely. If WSI_TIMEOUT is used, WSI_TIMEDOUT will indicate whether or not the command ended successfully. If it timed out WSI_TIMEDOUT will be set to TRUE otherwise, if the image was found within the time out period it will be set to FALSE
Re: Marcus
Good night,Good evening, that timedout worked perfectly with "D", now the problem is with the code below, whether or not the image is found, the code is executed, any ideas on how to solve it? Thanks.
FindImagePos>%BMP_DIR%\image_6.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Wait>1
Goto>Inicio
Endif
FindImagePos>%BMP_DIR%\image_6.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Wait>1
Goto>Inicio
Endif
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Marcus
I recommend turning on logging in the logging tab of the editor so you can see exactly what's happening.
It's also worth learning how to use the debugger : https://help.mjtnet.com/article/42-usin ... t-creation
It's also worth learning how to use the debugger : https://help.mjtnet.com/article/42-usin ... t-creation
Re: Marcus
I already use debug, but I want to locate an image on the screen, if found, click on it, if it doesn't find the image, in this case NumFound has a value of zero and I couldn't execute the codes below, but whether or not the image is found, the code inside the whether it is executed. The value of "NumFound" is always 1, whether the image is found or not.
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Wait>15
Goto>Miniaturas_Water
Endif
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Wait>15
Goto>Miniaturas_Water
Endif
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Marcus
Your most recent example uses a tolerance of 0 whereas the prior one used 0.7. This could account for the false positive with NumFound.
FindImagePosition
Tolerence should be given a value between 0 and 1 where 1 is a precise match and 0 is the least precise. A value of 0.7 is recommended and should allow for subtle variations in the images and works best for portability. The lower the value the more likely false positives will be observed
FindImagePosition
Tolerence should be given a value between 0 and 1 where 1 is a precise match and 0 is the least precise. A value of 0.7 is recommended and should allow for subtle variations in the images and works best for portability. The lower the value the more likely false positives will be observed