FindWindowEx 找不到出现在远程桌面连接上的 MessageBox
FindWindowEx doesn't find MessageBox appearing over Remote Desktop Connection
我们有一台构建机器,我们每天都在上面构建并在我们开发的应用程序上执行测试。问题是一些测试失败了,因为我们的一些可执行文件崩溃了。如果它们正常崩溃,那将只是一次失败的测试。
但相反,他们失败了,弹出窗口阻止他们完成。他们将在一定时间(通常为 5-10 分钟)后被杀死。我们通过创建一个定期检查弹出窗口并在发现时关闭它们的 "watchdog" 来解决这个问题。 python 检查代码在这里:
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
问题是MessageBox
在远程桌面连接登录上面,用之前的方法找不到。在我登录到远程桌面连接弹出窗口后,定期调用的函数发现了。
MessageBox 来自 csrss.exe(我在 Process Explorer 中看到了这个)并包含以下文本:
"XXXXX.exe - Application Error"
"The instruction at <...> referenced memory at <...> . The memory could not be read."
点击确定终止程序
点击取消调试程序
我可以这样做:Can the "Application Error" dialog box be disabled?
但我想知道为什么 FindWindowEx
在这种情况下找不到 MessageBox。我应该怎么做才能找到那个 MessageBox,有什么想法吗?
谢谢!
稍后编辑:
可以找到禁用弹出窗口的解决方案 here.
我选择不显示弹出窗口。
我们有一台构建机器,我们每天都在上面构建并在我们开发的应用程序上执行测试。问题是一些测试失败了,因为我们的一些可执行文件崩溃了。如果它们正常崩溃,那将只是一次失败的测试。
但相反,他们失败了,弹出窗口阻止他们完成。他们将在一定时间(通常为 5-10 分钟)后被杀死。我们通过创建一个定期检查弹出窗口并在发现时关闭它们的 "watchdog" 来解决这个问题。 python 检查代码在这里:
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
问题是MessageBox
在远程桌面连接登录上面,用之前的方法找不到。在我登录到远程桌面连接弹出窗口后,定期调用的函数发现了。
MessageBox 来自 csrss.exe(我在 Process Explorer 中看到了这个)并包含以下文本:
"XXXXX.exe - Application Error"
"The instruction at <...> referenced memory at <...> . The memory could not be read."
点击确定终止程序
点击取消调试程序
我可以这样做:Can the "Application Error" dialog box be disabled?
但我想知道为什么 FindWindowEx
在这种情况下找不到 MessageBox。我应该怎么做才能找到那个 MessageBox,有什么想法吗?
谢谢!
稍后编辑: 可以找到禁用弹出窗口的解决方案 here.
我选择不显示弹出窗口。