Show / Hide Table of Contents

Class ElementAssistant

Application ElementAssistant with fluent methods to help you manipulate AutomationElements in callback EventHandlers.
Instantiated with GPAL.ElementAssistant

Inheritance
System.Object
ElementAssistant
Implements
IAllowForSelector
IAllowElementSettingsAndActions
IAllowElementSetting
IAllowElementActions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: GenerallyPositive.Application
Assembly: GPAL.dll
Syntax
public class ElementAssistant : IAllowForSelector, IAllowElementSettingsAndActions, IAllowElementSetting, IAllowElementActions
Examples
// CallIfFound handler
public static int FoundNotepadPane(Application application, List<GPALAutomationElement> foundElements, List<GPALAutomationElement> matchedElements, Selector selector)
{
    ElementAssistant elementAssistant = (ElementAssistant) GPAL.ElementAssistant(application);

    foreach (GPALAutomationElement element in foundElements)
    {
        elementAssistant
            .ForSelector(selector)  // for interaction type, offsetX and offsetY
            .WithElement(element)
            .WithHardware  // can override the selector interaction type here for this one elem
            .LeftClick();
    }
    return 0;
}

Properties

WithHardware

Interact with the GPALAutomationElement emulating hardware, not using UIAutomation;

Declaration
public IAllowElementSettingsAndActions WithHardware { get; }
Property Value
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

Methods

AppendFrom(String)

Appends text to the end of the input GPALAutomationElement defined with .WithElement

Declaration
public IAllowElementSettingsAndActions AppendFrom(string inputText)
Parameters
Type Name Description
System.String inputText
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

FillInFrom(String)

Fill In (Ovewrite) text of the input GPALAutomationElement defined with .WithElement

Declaration
public IAllowElementSettingsAndActions FillInFrom(string inputText)
Parameters
Type Name Description
System.String inputText
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

ForSelector(Selector)

The selector associated with the webelement(s) you are acting upon.
Used for the OffestX and OffsetY properties and Information and Exceptional channel messages.

Declaration
public IAllowElementSetting ForSelector(Selector selector)
Parameters
Type Name Description
Selector selector
Returns
Type Description
IAllowElementSetting

Fluent interface to write your element handling workflow

InsertFrom(String)

Insert text at the beginning of the input GPALAutomationElement defined with .WithElement

Declaration
public IAllowElementSettingsAndActions InsertFrom(string inputText)
Parameters
Type Name Description
System.String inputText
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

LeftClick(Enums.ModifierKeys)

Left click the GPALAutomationElement, optionally emulating pressing a modifier key at the same time.

Declaration
public IAllowElementSettingsAndActions LeftClick(Enums.ModifierKeys modifierKeys = Enums.ModifierKeys.None)
Parameters
Type Name Description
Enums.ModifierKeys modifierKeys

Optional modifier key press

Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

LeftDoubleClick()

Left double click the GPALAutomationElement.

Declaration
public IAllowElementSettingsAndActions LeftDoubleClick()
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

PressModifierKey(Enums.ModifierKeys)

Press a modifier key: Alt, Control, Shift

Declaration
public IAllowElementSettingsAndActions PressModifierKey(Enums.ModifierKeys modifierKeys)
Parameters
Type Name Description
Enums.ModifierKeys modifierKeys

Alt, Control, Shift

Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

ReleaseModifierKey(Enums.ModifierKeys)

Release a modifier key: Alt, Control, Shift

Declaration
public IAllowElementSettingsAndActions ReleaseModifierKey(Enums.ModifierKeys modifierKeys)
Parameters
Type Name Description
Enums.ModifierKeys modifierKeys

Alt, Control, Shift

Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

RightClick()

Right click the GPALAutomationElement.

Declaration
public IAllowElementSettingsAndActions RightClick()
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

ScrollHorizontal(ScrollAmount)

Declaration
public IAllowElementSettingsAndActions ScrollHorizontal(ScrollAmount scrollAmount)
Parameters
Type Name Description
System.Windows.Automation.ScrollAmount scrollAmount
Returns
Type Description
IAllowElementSettingsAndActions

ScrollHorizontalPercent(Int32)

Declaration
public IAllowElementSettingsAndActions ScrollHorizontalPercent(int percent)
Parameters
Type Name Description
System.Int32 percent
Returns
Type Description
IAllowElementSettingsAndActions

ScrollVertical(ScrollAmount)

Declaration
public IAllowElementSettingsAndActions ScrollVertical(ScrollAmount scrollAmount)
Parameters
Type Name Description
System.Windows.Automation.ScrollAmount scrollAmount
Returns
Type Description
IAllowElementSettingsAndActions

ScrolVerticalPercent(Int32)

Declaration
public IAllowElementSettingsAndActions ScrolVerticalPercent(int percent)
Parameters
Type Name Description
System.Int32 percent
Returns
Type Description
IAllowElementSettingsAndActions

SendKeyCode(Byte)

Emulate pressing a special key like Home, End, Page Down.
Use GPAL.VK_ defined virual keycodes or send any you want to send.
https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

Declaration
public IAllowElementSettingsAndActions SendKeyCode(byte keyCode)
Parameters
Type Name Description
System.Byte keyCode
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

WithElement(GPALAutomationElement)

Define the GPALAutomationElement to act upon.

Declaration
public IAllowElementSettingsAndActions WithElement(GPALAutomationElement AutomationElement)
Parameters
Type Name Description
GPALAutomationElement AutomationElement
Returns
Type Description
IAllowElementSettingsAndActions

Fluent interface to write your element handling workflow

Implements

IAllowForSelector
IAllowElementSettingsAndActions
IAllowElementSetting
IAllowElementActions
In This Article
Back to top Generated by DocFX