How to skip line of code with conditional

Good night people! I’m using the image recognition tool called BotCity, and I’m developing my Python code in it. I would like to know, how do I skip block1 to the second, if the first element of this block is not found by the BOT, the same thing I want to happen in the second Block.
Thanks in advance for your help.

In the image below, there is an example of a message that is displayed in Terminal when a code snippet does not find the image.

I don’t want any of the blocks to run when the image is not found. I want each block to only run if the image is found.

Condition for block skip is = If the image is not found to be clicked.

Below, I provide the source code in TXT for analysis.

1 Like

Hey @Rafael , welcome to our community!
That is a great question.
Since the self.find element returns an element if there is a match and None otherwise we can wrap your logic using the positive check instead of the negative.

By default, the BotCity Studio generates a code that checks if there was no match if not self.find(...) but you can adapt your code to make blocks only be executed if self.find(...) which means that it will only be executed if there is a match.

Here is what I mean by that:

if self.find("EncontrarSeguir", matching=0.97, waiting_time=10000):
    # Do the process ONLY if it finds the `follow` image
    ...

if self.find("EncontrarCurtir", matching=0.97, waiting_time=10000):
     # Do the process ONLY if it finds the `like` image
     ...

In this case, instead of thinking about the logic to skip, think about the logic to execute the code.

Let me know if that helps.

1 Like

Good morning mr hslepicka, thanks for the reply. Unfortunately it didn’t work out, but it was my mistake for not having put together a good question. I’ll rephrase my analysis a little more precisely so you can solve my problem at any time.