Marcus

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
alugopejr
Newbie
Posts: 4
Joined: Sat Jan 20, 2024 7:14 pm

Marcus

Post by alugopejr » Sat Jan 20, 2024 7:24 pm

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

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Marcus

Post by Dorian (MJT support) » Mon Jan 22, 2024 10:57 am

It took me quite a while to spot this, as it's an easy mistake to make.

This:

Code: Select all

If>WSI_TIMEOUT=FALSE
Should be this :

Code: Select all

If>WSI_TIMEDOUT=FALSE
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
Yes, we have a Custom Scripting Service. Message me or go here

alugopejr
Newbie
Posts: 4
Joined: Sat Jan 20, 2024 7:14 pm

Re: Marcus

Post by alugopejr » Wed Jan 24, 2024 2:38 am

Work 100%. Thanks

alugopejr
Newbie
Posts: 4
Joined: Sat Jan 20, 2024 7:14 pm

Re: Marcus

Post by alugopejr » Wed Jan 24, 2024 11:02 pm

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

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Marcus

Post by Dorian (MJT support) » Thu Jan 25, 2024 12:23 am

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
Yes, we have a Custom Scripting Service. Message me or go here

alugopejr
Newbie
Posts: 4
Joined: Sat Jan 20, 2024 7:14 pm

Re: Marcus

Post by alugopejr » Thu Jan 25, 2024 2:04 am

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

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Marcus

Post by Dorian (MJT support) » Thu Jan 25, 2024 8:20 am

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
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts