ToolStripStatusLabelを使用したUIAutomation
-
06-07-2019 - |
質問
WinFormsアプリを使用していますが、UIAutomationを介して ToolStripStatusLabel
のテキストにアクセスできないようです。 Microsoft のサポートが示唆する
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を介して何らかの方法でその値を取得できるようにすることを望んでいます。
解決
ToolStripStatusLabel
コントロールの .Text
に加えて、 AccessibleName
プロパティを設定します。同様のシナリオでホワイトを使用することで機能します:
statusLabel.Text = statusLabel.AccessibleName ="新しいステータス値&quot ;;
他のヒント
テキストが異なる2つの独立したラベルを作成し、適切なラベルを表示および非表示にすることで、この問題を回避する必要がありました。これは私の目的(ホワイトでのテスト)には十分ですが、UIAutomationがテキスト値を表示しないことに非常に驚いています-基本的に、WinFormsアプリケーションのステータスバーのすべてのテキストはスクリーンリーダーにアクセスできないことを意味します。
あなたが説明したのと同様のラベルのテキストを取得する際に問題が発生したことはありません。実際、 AutomationId
は私のアプリケーションでも同じです。 ControlType
が ControlType.Edit
として表示されているという事実は誤解を招きます。例えば以下が動作します
statusText = (string)automationElement.GetCurrentPropertyValue(ValuePattern.ValueProperty);
automationElement
は、" StatusBar.Pane0"の
。 AutomationId
を使用して、 ControlType.Edit
に対してFindメソッドを使用して検索されました。