Forum Discussion

Rafael_Fradczyk's avatar
Rafael_Fradczyk
Occasional Contributor
10 years ago

Combine "if...then" statement with image recognition

Hi,

my problem is, I don't want to use the "if...then" statement to check an object property but to check an image. Like I want to check if an image appears on the screen AND looks like image "A". Then do something. If not so do something else.



Is there a way to do this in the keyword script?

Thanks in advance.

Armin

4 Replies

  • Deleted original post as you can't check an image within an if statement as far as I can see but will post another reply soon :)



    Edit:



    Can you not do something like



    (If) Object Property of Drawing is Visible (then) Compare Pictures



    (else) Do something else



    I think that makes sense, as if the drawing is not visible then there's no point comparing the images to check if they are the same, but if its visible then check if they are the same or move on to your else.
  • Rafael_Fradczyk's avatar
    Rafael_Fradczyk
    Occasional Contributor
    Thanks for your answer, but that's not exactly what I wanted to do. In your scenario I first check if the image is visible and then compare the image to another. But what I wanted was, first compare the image to another and then depending on whether the image is the same or not do something.



    I solved it now as follows:



    1. ComparePictures

    I stored one picture in regions and compared it to an onscreen object



    2. If...then

    LastResult equals true



    Now if the images are the same the "then" condition will be executed otherwise the "else" condition.





  • Yeah that sounds correct, sorry I misunderstood your question, but atleast you have solved your issue now :)
  • I don't think you did.



    What if the onscreen object is not present/visible?



    I assume you have some sort of error handling in there to account for this. Otherwise, I would suggest Lee's original answer (only compare if it's present in the first place) makes more sense ...