Choosing second image if first isn't available

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Crumpledpapr
Newbie
Posts: 3
Joined: Sun Jun 09, 2019 3:13 pm

Choosing second image if first isn't available

Post by Crumpledpapr » Mon Jun 10, 2019 4:41 am

Hi I'm having issues trying to figure out how to create a either or scenario with image recognition. Basically I'm running a loop waiting for one of two images to come up, finding either one and clicking and moving on with the script. Any help would be appreciated.

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

Re: Choosing second image if first isn't available

Post by Dorian (MJT support) » Mon Jun 10, 2019 10:05 pm

How about something like this?

Code: Select all

//Wait until either of two images appears by using a While Loop

Let>AnImageWasFound=FALSE
While>AnImageWasFound=FALSE
  //Here we use two FindImagePos statements - one for each image
  FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound1,CCOEFF
  FindImagePos>%BMP_DIR%\image_3.bmp,SCREEN,0.7,1,XArr,YArr,NumFound2,CCOEFF
  //Now we see if one or other was found
  If>NumFound1>0
    //First Image Was Found - do something
  
    .. your  code here - or run a subroutine or goto a label or something
    
    //set AnImageWasFound flag to end the While loop
    Let>AnImageWasFound=TRUE
  Else
    If>NumFound2>0
      //Second Image Was Found - do something else
      .. your  code here - or run a subroutine or goto a label or something
      //set AnImageWasFound flag to end the While loop
    Let>AnImageWasFound=TRUE
    Endif
  Endif
EndWhile
//When we get here one of the images was found and acted on
Always accepting custom script commissions. Message me or go here

Crumpledpapr
Newbie
Posts: 3
Joined: Sun Jun 09, 2019 3:13 pm

Re: Choosing second image if first isn't available

Post by Crumpledpapr » Tue Jun 11, 2019 3:20 am

That worked perfectly thank you so much

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

Re: Choosing second image if first isn't available

Post by Dorian (MJT support) » Thu Jun 13, 2019 2:36 pm

You are very welcome.
Always accepting custom script commissions. Message me or go here

Post Reply