Skip to content

WinEvents.Action

Avrigeanu Laurian edited this page Sep 5, 2022 · 9 revisions

DesktopScreenshot (String)

This method will take a screenshot of the desktop and save it to a path.

Mandatory Parameters
string saveToPath

Example:

var screenshotPath = WinEvents.Action.DesktopScreenshot("C:\Users\MyUser\Desktop\myScreenshot.jpeg");

ElementScreenshot (String)

This method will take a screenshot of an element and save it to a path.

Mandatory Parameters
AutomationElement element
string saveToPath

Example:

var screenshotPath = WinEvents.Action.ElementScreenshot(element, "C:\Users\MyUser\Desktop\myScreenshot.jpeg");

GetText (String)

This method will retrieve the text of the given element.

Mandatory Parameters Optional Parameters
AutomationElement element int retries (default:15)
  double retryInterval (default 1)

Example:

var elementText = WinEvents.Action.GetText(element);

SendText (Bool)

This method will send text to an element, either by changing the text attribute of the element or by sending keys, the latter will trigger any event that the application might have when an user inserts a value in the element.

Mandatory Parameters Optional Parameters
AutomationElement element int retries (default:15)
string text  double retryInterval (default 1)
  bool eventTrigger (default false)

Example:

var sendText = WinEvents.Action.SendText(element, "The text I want to send.");

Click (Bool)

This method will click a given element, there is a parameter to enable whether the mouse should move to the element before clicking it, or simulating the click.

Warning: Simulating clicks might not always be supported by the element.

Mandatory Parameters Optional Parameters
AutomationElement element int retries (default:15)
   double retryInterval (default 1)
  bool invoke (default false)

Example:

var clickElement = WinEvents.Action.Click(element);

DoubleClick (Bool)

This method will double click a given element, there is a parameter to enable whether the mouse should move to the element before clicking it, or simulating the click.

Warning: Simulating clicks might not always be supported by the element.

Mandatory Parameters Optional Parameters
AutomationElement element int retries (default:15)
   double retryInterval (default 1)
  bool invoke (default false)

Example:

var clickElement = WinEvents.Action.DoubleClick(element);

RightClick (Bool)

This method will right click a given element, there is a parameter to enable whether the mouse should move to the element before clicking it, or simulating the click (simulating the click is not supported as of yet).

Warning: Simulating clicks might not always be supported by the element.

Mandatory Parameters Optional Parameters
AutomationElement element int retries (default:15)
   double retryInterval (default 1)
  bool invoke (default false)

Example:

var clickElement = WinEvents.Action.RightClick(element);

SendKeys (void)

This method will send a key globally, in whichever window is currently active.

Mandatory Parameters
VirtualKeyShort keyShort

Example:

WinEvents.Action.SendKeys(VirtualKeyShort.KEY_A);

SendKeyCombination (void)

This method will send a key combination globally, in whichever window is currently active.

Mandatory Parameters
VirtualKeyShort[] keyShorts

Example:

WinEvents.Action.SendKeyCombination(new VirtualKeyShort[] {VirtualKeyShort.CONTROL, VirtualKeyShort.KEY_C});

Clone this wiki locally