Implementando o padrão de controle Invoke de automação de interface de usuário
Observação
Esta documentação destina.Os desenvolvedores do NET Framework que desejam usar o gerenciado UI Automation classes definidas na System.Windows.Automation namespace.As informações mais recentes sobre UI Automation, consulte API de automação do Windows: Automação da interface do usuário.
This topic introduces guidelines and conventions for implementing IInvokeProvider, including information about events and properties. Links to additional references are listed at the end of the topic.
The InvokePattern control pattern is used to support controls that do not maintain state when activated but rather initiate or perform a single, unambiguous action. Controls that do maintain state, such as check boxes and radio buttons, must instead implement IToggleProvider and ISelectionItemProvider respectively. For examples of controls that implement the Invoke control pattern, see Mapeamento de Padrão de Controles para Clientes de Automação de IU.
Este tópico contém as seguintes seções.
- Implementation Guidelines and Conventions
- Required Members for IInvokeProvider
- Exceptions
- Tópicos relacionados
Implementation Guidelines and Conventions
When implementing the Invoke control pattern, note the following guidelines and conventions:
Controls implement IInvokeProvider if the same behavior is not exposed through another control pattern provider. For example, if the Invoke method on a control performs the same action as the Expand or Collapse method, the control should not implement IInvokeProvider.
Invoking a control is generally performed by clicking or double-clicking or pressing ENTER, a predefined keyboard shortcut, or some alternate combination of keystrokes.
InvokedEvent is raised on a control that has been activated (as a response to a control carrying out its associated action). If possible, the event should be raised after the control has completed the action and returned without blocking. The Invoked event should be raised before servicing the Invoke request in the following scenarios:
It is not possible or practical to wait until the action is complete.
The action requires user interaction.
The action is time-consuming and will cause the calling client to block for a significant amount of time.
If invoking the control has significant side-effects, those side-effects should be exposed through the HelpText property. For example, even though Invoke is not associated with selection, Invoke may cause another control to become selected.
Hover (or mouse-over) effects generally do not constitute an Invoked event. However, controls that perform an action (as opposed to cause a visual effect) based on the hover state should support the InvokePattern control pattern.
Observação
This implementation is considered an accessibility issue if the control can be invoked only as a result of a mouse-related side effect.
Invoking a control is different from selecting an item. However, depending on the control, invoking it may cause the item to become selected as a side-effect. For example, invoking a Microsoft Word document list item in the My Documents folder both selects the item and opens the document.
An element can disappear from the UI Automation tree immediately upon being invoked. Requesting information from the element provided by the event callback may fail as a result. Pre-fetching cached information is the recommended workaround.
Controls can implement multiple control patterns. Por exemplo, o controle de cor de preenchimento na Microsoft Excel barra de ferramentas implementa ambos os InvokePattern e o ExpandCollapsePattern padrões de controle. ExpandCollapsePatternexpõe o menu e o InvokePattern preenche a seleção ativa com as cores escolhidas.
Required Members for IInvokeProvider
The following properties and methods are required for implementing IInvokeProvider.
Required members |
Member type |
Notes |
---|---|---|
method |
Invoke is an asynchronous call and must return immediately without blocking. This behavior is particularly critical for controls that, directly or indirectly, launch a modal dialog when invoked. Qualquer o cliente de automação da interface do usuário que o evento que atraiu permanecerá bloqueado até que a caixa de diálogo modal está fechada. |
Exceptions
Providers must throw the following exceptions.
Exception Type |
Condition |
---|---|
If the control is not enabled. |
Consulte também
Tarefas
Support Control Patterns in a UI Automation Provider
Invocando um Controle Utilizando Automação de IU
Conceitos
Visão Geral de Padrões de Controle de Automação de Interface de Usuário