Detect diffrent immages

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ammone95
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 9:43 pm

Detect diffrent immages

Post by ammone95 » Tue Feb 28, 2017 9:58 pm

Hi, I need to determinate different immages that pops up with a random but short period of time (from 30 secs to 5 mins).
What i want to do is a WaitScreenImage, FindImagePos and LClick an image, if that image didn't show up i want to check if another one comes up and do the same thing as the first one. If not, repeat the same process for about 5 images...
Is it possible? I know how to find an image and click it, what i can't do is the switch between different images. I know how to do it in C++ but it doesn't work on here...
Any suggestions?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Detect diffrent immages

Post by Marcus Tettmar » Wed Mar 01, 2017 4:03 pm

I think what you are saying is you want to keep checking to see if any one of a bunch of images appears. You don't know when which will pop up, so you want to keep checking until one of them does. To do this just put multiple FindIMagePos checks inside a loop. Keep looping until one is found.

Psuedocode:

Code: Select all

Let>found=0
While>found=0
  FindImagePos>image1 ....
  If>found=1
    MouseMove>...
    LClick
  Else
    FindImagePos>image2...
    If>found=1
      MouseMove>...
      LClick 
    Else
     ..
     ... etc
    Endif
 Endif
 Wait>0.02
EndWhile
This code will check to see if image1 exists. If not it will check to see if image2 exists ... add more nested ifs for more images. At the end it will see if any were found. If not it will loop back and keep checking.

Consider that WaitScreenImage is nothing more than FindImagePos in a loop. Well here we have a multiple FindImagePos loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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