1

私は WinForms アプリを持っていますが、ToolStripStatusLabelUIAutomation を介して a のテキストにアクセスできないようです。Microsoftは、 s (およびおそらくその中の項目)のサポートが制限されていることを暗示StatusStripしていますが、これは機能する必要がある基本的な使用例のようです。

コントロールはControlType.EditUISpy で表示され、読み取り専用のテキスト ボックスのように見えますが、値はテキストではなく常に名前と同じです。

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 を介して何らかの方法でその値を取得できることを望んでいます。

4

3 に答える 3

1

コントロールにAccessibleName加えてプロパティを設定します。同様のシナリオで White を使用するとうまくいきます。.TextToolStripStatusLabel

statusLabel.Text = statusLabel.AccessibleName = "New status value";

于 2013-03-14T03:46:17.173 に答える
0

あなたが説明したものと同様のラベルのテキストを取得する際に問題が発生したことはありません. 実際、AutomationId私のアプリケーションでも同じです。ControlTypeとして示されているという事実ControlType.Editは誤解を招くものです。たとえば、次のように動作します

statusText = (string)automationElement.GetCurrentPropertyValue(ValuePattern.ValueProperty);

automationElementに対して Find メソッドを使用して検索されControlType.Editた場所。AutomationId"StatusBar.Pane0"

于 2009-08-18T03:09:05.187 に答える