如何设置isKeyboardFocusable = true?

时间:2014-11-24 21:46:09

标签: c# wpf user-interface automation

我正在尝试自动化WPF应用程序的登录过程。我用UISpy来获取下面的属性。

我无法在AutomationElement上调用Focus()和SetFocus()。它抛出错误“目标元素无法获得焦点”

如何将isKeyboardFocusable属性更改为true或如何解决此问题?

AutomationElement
  General Accessibility
    AccessKey:  ""
    AcceleratorKey: ""
    IsKeyboardFocusable:    "False"
    LabeledBy:  "(null)"
    HelpText:   ""

  State
    IsEnabled:  "True"
    HasKeyboardFocus:   "False"

  Identification
    ClassName:  ""
    ControlType:    "ControlType.Edit"
    Culture:    "(null)"
    AutomationId:   ""
    LocalizedControlType:   "edit"
    Name:   ""
    ProcessId:  "15656 (iexplore)"
    RuntimeId:  "42 10487454 2 3 1 0"
    IsPassword: "False"
    IsControlElement:   "True"
    IsContentElement:   "True"

  Visibility
    BoundingRectangle:  "(1155, 363, 212, 20)"
    ClickablePoint: "(null)"
    IsOffscreen:    "False"

ControlPatterns
  Value
    Value:  ""
    IsReadOnly: "False"

0 个答案:

没有答案