How can I 'OR' a search?

Sometimes you need to do something if image A or image B appears. For example, you wait for dialog box A or B.

The solution is to store the visualSearch image search result for each image in a variable, and then use standard Javascript || to “OR” it. In the test below in the first run no image is found, then one, and finally both:

macro:

{
  "Name": "OR search",
  "CreationDate": "2021-3-18",
  "Commands": [
    {
      "Command": "store",
      "Target": "3",
      "Value": "!timeout_wait"
    },
    {
      "Command": "visualSearch",
      "Target": "logo_dpi_168.png",
      "Value": "a"
    },
    {
      "Command": "visualSearch",
      "Target": "rpa_dpi_168.png@0.8",
      "Value": "b"
    },
    {
      "Command": "echo",
      "Target": "a=${a} b=${b}",
      "Value": ""
    },
    {
      "Command": "if_v2",
      "Target": "Number (${a}) > 0 || Number (${b}) > 0",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "A and/or B are found!",
      "Value": "green"
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "No image found!",
      "Value": "blue"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}

is there a way to visualSearch more than one image in one ago?

instead of doing two separate visualSearch.

My situation is I am checking for two conditions that might appear. It is possible that neither condition appears. If it is neither, then I end up wasting the timeout_wait period x 2, even if it is a few seconds, it adds up to a lot of wasted time over lots of loops.

If you set !timeout_wait to 0 then VisualSearch only does one search per image, so there is no additional delay.