This project is read-only.

Access controls of a process with no "window"

Mar 10, 2010 at 9:17 PM

I have a process running that, in certain display configurations, has no "windows" to work with. The application has a display mode that turns it into, more or less, a floating toolbar. UISpy does not register this "toolbar" as a window but has the edit control that I am trying to access listed. Here is a mock up of the UISpy window


"pane" "" (Desktop Window)

  "pane" ""

  "pane" ""

  "window" "Bin"

  "edit" ""          <---------------   this is the control I'm looking to manipulate

  "button" "Input"


The properties of "edit" "" look like this.


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

    IsEnabled:				"True"
    HasKeyboardFocus:			"False"

    ClassName:				"Edit"
    ControlType:			"ControlType.Edit"
    Culture:				"(null)"
    AutomationId:			"2023"
    LocalizedControlType:		"edit"
    Name:				""
    ProcessId:				"5944 (MyAppName)"
    RuntimeId:				"42 854250"
    IsPassword:				"False"
    IsControlElement:			"True"
    IsContentElement:			"True"

    BoundingRectangle:			"(608, 12, 102, 17)"
    ClickablePoint:			"658,20"
    IsOffscreen:			"False"

      Text:				""
      Length:				"0"
      Bounding Rectangles:		""
      AnimationStyleAttribute:		"(not supported)"
      BackgroundColorAttribute:		"16777215"
      BulletStyleAttribute:		"(not supported)"
      CapStyleAttribute:		"None"
      CultureAttribute:			"(not supported)"
      FontNameAttribute:		"Tahoma"
      FontSizeAttribute:		"8"
      FontWeightAttribute:		"400"
      ForegroundColorAttribute:		"0"
      HorizontalTextAlignmentAttribute:	"Left"
      IndentationFirstLineAttribute:	"(not supported)"
      IndentationLeadingAttribute:	"(not supported)"
      IndentationTrailingAttribute:	"(not supported)"
      IsHiddenAttribute:		"(not supported)"
      IsItalicAttribute:		"False"
      IsReadOnlyAttribute:		"False"
      IsSubscriptAttribute:		"(not supported)"
      IsSuperscriptAttribute:		"(not supported)"
      MarginBottomAttribute:		"(not supported)"
      MarginLeadingAttribute:		"(not supported)"
      MarginTopAttribute:		"(not supported)"
      MarginTrailingAttribute:		"(not supported)"
      OutlineStylesAttribute:		"(not supported)"
      OverlineColorAttribute:		"(not supported)"
      OverlineStyleAttribute:		"(not supported)"
      StrikethroughColorAttribute:	"(not supported)"
      StrikethroughStyleAttribute:	"None"
      TabsAttribute:			"(not supported)"
      TextFlowDirectionsAttribute:	"(not supported)"
      UnderlineColorAttribute:		"(not supported)"
      UnderlineStyleAttribute:		"None"

    Value:				""
    IsReadOnly:				"False"


How would I access this control using white?


Mar 11, 2010 at 1:19 AM

Using automation element, try the following

AutomationElement aeTextBox = Core.Desktop.Instance.AutomationElement.FindFirst
                (TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "2023"));

            TextPattern tp = aeTextBox.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
            string str = tp.DocumentRange.GetText(-1);