ui-automation – Microsoft UI Automation:调用模式异常
发布时间:2020-12-13 21:25:22 所属栏目:Windows 来源:网络整理
导读:我试图使用调用模式单击一个按钮. InvokePattern ipAddMPButton = (InvokePattern)aeAddMPButton.GetCurrentPattern(InvokePattern.Pattern); try { ipAddMPButton .Invoke(); } catch (System.Runtime.InteropServices.COMException e) { // TODO } 它抛出C
我试图使用调用模式单击一个按钮.
InvokePattern ipAddMPButton = (InvokePattern)aeAddMPButton.GetCurrentPattern(InvokePattern.Pattern); try { ipAddMPButton .Invoke(); } catch (System.Runtime.InteropServices.COMException e) { // TODO } 它抛出COMException,我无法弄清楚为什么? 当我运行此代码时,按钮实际上被按下,功能正常.但随后它会停止一段时间,并抛出此异常.
实际上我发现这已经在这里讨论了:
https://social.msdn.microsoft.com/Forums/en-US/673bba3d-27b3-4374-b049-0d2e8ec5e462/hang-with-invokepattern-invoke-in-virtual-pc?forum=windowsaccessibilityandautomation.总而言之,Winforms打开模态对话框与UIAutomation不能很好地协作,因为它不会从Invoke命令返回,只会创建模式对话框,这当然会阻止它完成操作.建议的解决方案是生成后台线程并从该线程激活Invoke(或任何其他操作).我还建议在完成操作时强制执行某种超时,因为在某些情况下它可能很长.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-server-2008 – Windows Web Server 2008 R2 Max R
- 如何在Windows上将Bitbucket项目导入Github
- windows – 打开WDK Projects会导致出现“发生一个或多个错
- Windows批处理文件读取文本文件并将全部转换为大写
- 带有标题和项模板列的Windows 8 XAML ListView应具有相同的
- windows – 如何在C/C++程序中使用静态地址?
- windows下tomcat单机多实例部署
- 2019年5月最新win10教育版1903激活密钥和下载
- windows-server-2008 – Windows 2008 R1上的IIS管理PowerS
- windows – 如何将std = c 11标志添加到clang-cl?