You’ll want to look at the built-in Omega13 script (type “Omega13” into the text field at the bottom of the Run window and hit return) that overrides the image-based commands so that if an image is not found, you can check to see whether a predefined condition exists or simply take action to bring focus back to your application. To use it you first need to create a script called “AttemptRecovery”. This script must be written to either deal with a specific popup (or popups) or to bring your application back to the foreground; as such, creating the script may be an iterative process as new conditions arise. Once you have the script written, you can add the following line to any other script:
start using Omega13
Once you do that, all subsequent commands and functions that target images will be overridden such that if they fail with an “image not found” condition, they will call out to your AttemptRecovery script. That script is then executed and can try to resolve any known issues that would prevent the image from being found before returning control to the Omega13 script, which then tries again to locate the image and if successful, your script continues as though no problem had occurred.