我有一个WinForms应用程序,但我似乎无法通过UIAutomation访问ToolStripStatusLabel的文本。微软implies表示,对StatusStrip的支持(以及其中的项目)是有限的,但这似乎是一个足够基本的用例,它应该可以工作。
该控件在UISpy中与ControlType.Edit一起显示,并且显示为只读文本框,但是它的值始终与其名称相同,而不是与其文本相同。
UISpy中的属性如下:
AutomationElement
General Accessibility
AccessKey: ""
AcceleratorKey: ""
IsKeyboardFocusable: "False"
LabeledBy: "(null)"
HelpText: ""
State
IsEnabled: "True"
HasKeyboardFocus: "False"
Identification
ClassName: ""
ControlType: "ControlType.Edit"
Culture: "(null)"
AutomationId: "StatusBar.Pane0"
LocalizedControlType: "edit"
Name: "My Label"
ProcessId: "3972 (*****)"
RuntimeId: "42 134002 0"
IsPassword: "False"
IsControlElement: "True"
IsContentElement: "True"
Visibility
BoundingRectangle: "(9, 273, 79, 17)"
ClickablePoint: "48,281"
IsOffscreen: "False"
ControlPatterns
GridItem
Row: "0"
Column: "0"
RowSpan: "1"
ColumnSpan: "1"
ContainingGrid: ""status bar" "statusStrip""
Value
Value: "My Label"
IsReadOnly: "True"基本上,我希望有一些方法去myLabel.Text = "something",并能够通过UIAutomation以某种方式获得那个值。
发布于 2013-03-14 11:46:17
除设置ToolStripStatusLabel控件上的.Text外,还设置AccessibleName属性。它适用于我在类似的场景中使用怀特:
statusLabel.Text = statusLabel.AccessibleName = "New status value";
发布于 2009-06-26 08:51:30
我不得不通过使用两个具有不同文本的单独标签,并显示和隐藏适当的标签来解决这个问题。这足以满足我的目的(使用White进行测试),但我非常惊讶UIAutomation没有显示文本值-这基本上意味着WinForms应用程序中状态栏中的所有文本对于屏幕阅读器都是不可访问的。
发布于 2009-08-18 03:09:05
我在检索与您所描述的标签相似的文本时从来没有遇到过问题。事实上,在我的应用程序中,AutomationId甚至是相同的。将ControlType显示为ControlType.Edit的事实具有误导性。例如,以下方法将会起作用
statusText = (string)automationElement.GetCurrentPropertyValue(ValuePattern.ValueProperty);对AutomationId为"StatusBar.Pane0"的ControlType.Edit使用Find方法定位automationElement的位置。
https://stackoverflow.com/questions/1007203
复制相似问题