User Case
User needs to handle error dialog by dismiss it whenever error dialog appears, however some time there are 2 error dialogs display and sometime no error dialog. Therefore "if window exists" and "identify windows" are used to determine if there is error dialog does not work in this case.
Solution
The following steps can be used to handle this situation. This only works in case each error dialog has its own process
1. Call “tasklist” (Windows command) to list out all running processes
2. Check if there is error dialog process
a. If there is error dialog process, call appropriate action on that dialog
b. If there are more than one error dialog, use “identify windows” to distinguish error dialogs before calling suitable action
Below sample script will close 1 of existing CMD windows