zoukankan      html  css  js  c++  java
  • UI Automation in WPF/Silverlight

    Concepts
    Peer: 每个Control类有一个Peer类,这个Peer类expose其对应的Control给UI Automation. Each AutomationPeer exposes the corresponding Microsoft .NET Framework control to Microsoft UI Automation.
    Control Pattern:Control patterns provide a way to categorize and expose a control's functionality independent of the control type or the appearance of the control. UI Automation uses control patterns to represent common control behaviors. For example, you use the Invoke control pattern for controls that can be invoked (such as buttons) and the Scroll control pattern for controls that have scroll bars (such as list boxes, list views, or combo boxes). Because each control pattern represents a separate functionality, they can be combined to describe the full set of functionality supported by a particular control.

    评论
    1.There is not a one-to-one correspondence between control types and control patterns. A control pattern may be supported by multiple control types, and a control may support multiple control patterns, each of which exposes different aspects of its behavior. For example, a combo box has at least two control patterns: one that represents its ability to expand and collapse, and another that represents the selection mechanism.
    2. Dynamic Control Pattern: Some controls do not always support the same set of control patterns. Control patterns are considered supported when they are available to a UI Automation client. For example, a multiline edit box enables vertical scrolling only when it contains more lines of text than can be displayed in its viewable area. Scrolling is disabled when enough text is removed so that scrolling is no longer required. For this example, the ScrollPattern control pattern is dynamically supported depending on the current state of the control (how much text is in the edit box).
    Provider:在Windows中使用的UI framework有好几种,比如Win32、Windows Forms和WPF。Microsoft UI Automation暴露UI element相关的信息给client。但是UI Automation并不知道各个UI framework之间的不同,更不了解其中所使用的技术。UI Automation把这个工作留给了一个叫provider的对象。一个provider从一个特定control上获取信息并将之以一种consistent的方式传给client。

    UI Automation providers enable controls to communicate with UI Automation client applications. In general, each control or other distinct element in a user interface (UI) is represented by a provider. The provider exposes information about the element and optionally implements control patterns that enable the client application to interact with the control.

    UI Automation providers fall into two categories: client-side providers and server-side providers.

    Client-side providers
    Client-side providers are implemented by UI Automation clients to communicate with an application that does not support, or does not fully support, UI Automation. Client-side providers usually communicate with the server across the process boundary by sending and receiving Windows messages.

    Because UI Automation providers for controls in Win32, Windows Forms, or WPF applications are supplied as part of the operating system, client applications seldom have to implement their own providers, and this overview does not cover them further.

    Server-side providers
    Server-side providers are implemented by custom controls or by applications that are based on a UI framework other than Win32, Windows Forms, or WPF.

    Server-side providers communicate with client applications across the process boundary by exposing interfaces to the UI Automation core system, which in turn serves requests from clients.

    Providers can exist either on the server side or on the client side. A server-side provider is implemented by the control itself.

    注: Provider分为Client-side和Server-side两种类型,并且Provider要么存在于Client端,要么存在于Server端。Server-side provider 是由control自己来实现的,而Client-Side不是由Control自己实现的,而是由UI Automation的client实现的。

    Client-side 与UI Process 之间通过发送和接受Windows Message来通信;Server-side提供interface,用于与Client application进行通信。

    下面的例子模仿了点击Button的行为:


    AutomationPeer BtnPeer = FrameworkElementAutomationPeer.CreatePeerForElement(HelloBtn);
    object invokepattern = BtnPeer.GetPattern(PatternInterface.Invoke);
    (invokepattern 
    as IInvokeProvider).Invoke();

  • 相关阅读:
    <Android 应用 之路> 聚合数据SDK
    AngularJS所有版本下载地址
    <Android 应用 之路> 天气预报(三)
    <Android 应用 之路> 天气预报(二)
    Java集合框架—Set
    HBase数据模型(2)
    HBase数据模型(1)
    ESP8266串口WiFi扩展板详解
    Arduino ESP8266编程深入要点
    <Android Framework 之路>多线程
  • 原文地址:https://www.cnblogs.com/holly/p/1750356.html
Copyright © 2011-2022 走看看