We have a build machine on which we do daily builds and execute tests at the application we develop. The problem is that some tests are failing because some of our executables are crashing. And if they would crash normally it would just be a failed test.
But instead of that they fail with a popup that prevents them from finishing. They will be killed after some determined time (5-10 minutes usually). We overcome this issue by creating a "watchdog" that periodically checks for popups and closes them when found. The python code for checking is here:
def CheckGenericPopupByClassName(hwnd,className):
# pass None for desktop popups
hwndPopup = None
hwndFirst = None
consecutiveExceptionCount = 0
# check for popups on Desktop
while True:
try:
hwndPopup = win32gui.FindWindowEx(hwnd, hwndPopup, className, None) # Check with Spy++ for class name
except Exception as e:
print("CheckGenericPopupByClassName exception:"+str(e))
hwndPopup = hwndFirst = None
consecutiveExceptionCount = consecutiveExceptionCount + 1
if consecutiveExceptionCount > 5:
return
continue
consecutiveExceptionCount = 0
if hwndPopup is None or hwndPopup is 0 or hwndPopup is hwndFirst:
break
if hwndFirst is None:
hwndFirst = hwndPopup
HandleGenericPopup(hwndPopup) # this closes the popup
The problem is that the MessageBox
is above the remote desktop connection login and is not found by the previous method. After I login to the remote desktop connection popups are found by the function that is periodically called.
The MessageBox is from csrss.exe (I saw this with Process Explorer) and has the following text:
"XXXXX.exe - Application Error"
"The instruction at <...> referenced memory at <...> . The memory could not be read."
Click on OK to terminate the program
Click on CANCEL to debug the program
I could do this: Can the "Application Error" dialog box be disabled?
But I want to know why FindWindowEx
doesn't find the MessageBox in this case. Any ideas what should I do to find that MessageBox?
Thanks!
Later Edit: The solution to disable the popups can be found here.
I chose to avoid showing the popup.
I used the solution from Microsoft site.