Ocr count / ocr repeat restriction

Hi,

I have a desktop automated robot where I’m using OCR to find a text in a pop-up window through a loop (it takes a while for the popup to load). If the text is found, a button needs to be clicked.

From time to time it happens that the text is not found. I’m not sure why. If that happens, the robot keeps processing the ocrsearch action because of the loop. This consumes all of my OCR conversions (500 max / pro license).

I was wondering if there is a possibility to maximize the number of conversions per OCRsearch action, to say 10x and stop the macro if that happens. Or maybe some other workaround to solve this issue.

Thanks!

rg, Maurice

I think I found a solution in this post.

I incorporated a loopcounter and created a ‘pause | 0’ to pause the macro.

I am glad to hear that you found a solution. Just to clarify: The OCRSearch does not do any retries. It is different from e. g. XClick | image where it retries to find the image until timeout. OCRSearch or XClick | ocr= is done once and then the text is returned.

Thanks for the reply.

The issue is that I must wait for a popup to show. When it does, I have to click a button inside the popup. The popup doesn’t show immediately. Sometimes it takes a second, sometimes 5 for instance. So I started with xclick | ocr= to search for the popup caption text.However, when it takes to long there is a timeout. Therefor I needed to use a loop (do repeatif).

The problem is that the caption text is sometimes not found. Can’t tell you why, because when I test it, it’s always found. When the macro runs unattended it’s sometimes not found. Then this loop is running until the OCR count is maxed. If so, I can’t restart the macro again.

So now I use a combination of the loop and the counter to stop if the loopcount is maxed.

Maybe there is a better way, but it works. It could be nice to have a variable somewhere to input the max number of OCR tries.

regards

I suggest to do it like this:

  1. visualAssert | unique_image.png <= Use visualAssert to wait for popup to appear

  2. XCLICK | OCR=text <= Once the popup is there, then use OCR.

This approach minimizes the number of OCR API calls. This is very useful if you use the default cloud OCR. If you have the local OCR server option (and thus very fast and unlimited OCR conversions) this does not matter.

Thank you. I will give this a try!