问题描述
我一直在使用 Windows SDK 中的 Inspect.exe 来检查 WinForms 应用程序的属性,但注意到在从 Visual Studio 运行应用程序时我没有看到任何属性(例如,AutomationId)(F5 运行.)但是,如果我从 bin\debug 文件夹中运行 .exe,我可以很好地看到属性.
I've been using Inspect.exe from the Windows SDK to examine the properties of a WinForms application but noticed that I didn't see any of the properties (for example, the AutomationId) whilst running the application from Visual Studio (F5 to run.) However, if I ran the .exe from the bin\debug folder I could see the properties fine.
我使用的源代码是从 UI 自动化下载的示例代码自定义提供程序示例 - 第 3 部分.
The source I was using was example code downloaded from UI Automation Custom Provider Samples - Part 3.
我想知道为什么会发生这种情况,因为我确定我试过的另一台机器工作正常,而且我浪费时间在调试模式下闲逛,想知道为什么我的 UI 自动化属性不可见.显然有一个解决方法,但我想了解为什么会发生这种情况,并记录问题以供其他人查找!
I'm wondering why this happened since I'm sure another machine that I had tried this on worked fine and I wasted time poking around in debug mode wondering why my UI Automation properties weren't visible. Obviously there's a workaround but I'd like to understand why this was happening and have a record of the problem for other people to find!
推荐答案
我找到了答案 - 因为我以管理员身份启动了 Visual Studio,但以标准用户身份启动了 Inspect.exe 工具,然后返回的属性是一个我应该看到的子集.当我以管理员身份启动 Inspect.exe 时,它就开始工作了!
I've struck upon the answer - because I had launched Visual Studio as Administrator but the Inspect.exe tool as standard user then the properties being reported back were a sub-set of what I should have seen. As soon as I launched Inspect.exe as Administrator it worked!
这篇关于为什么 Inspect.exe 在调试中运行时不显示 AutomationId 和其他 UIAutomation 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!