Using WPF Screen Elements During Runtime

You can use captured screen element types in your project. Below is an example of how to work with properties and functions of the WPF General screen element. The Monitor application is used during runtime in the example.

The WPF General screen element type is the basic type, meaning all other WPF screen element types inherit properties, functions, and events from this property, and may have their own additional functionality.

In this example, the functionality of the WPF General screen element is used to demonstrate how to work with the WPF screen element.

To interact with WPF screen elements during runtime:

1. Run the project and select Monitor. See also Running the Monitor.
2. Click the Screen Element tab. A full hierarchy of the captured WPF screen element is displayed (including hidden captures). Select the relevant WPF screen element in the tree on the left. The list of properties of the screen element is enabled in the Properties tab on the right:

In Monitor only properties of simple types are listed (Boolean, DateTime, Decimal, Number, Text). To get properties of other types (List type, Screen Element Rectangle type and other Libarary screen element types), you must bind them with business entities in the project.

3. Open the Functions tab.

The functions of the screen element are available in the Available Functions drop-down list:

Monitor displays only properties of simple types. The functions of other types, such as List of PO, PO and CtrlPO, are not shown. To use functions not shown in Monitor, you must define them in the Business Entities module in Real-Time Designer.

Simple Return Type Functions

The following simple return type functions are available in Monitor.

Bring to Front: This function moves the WPF object to the top of the stacking order (brings object to the front). To run this function, select Bring to Front in the Available Functions drop-down list, and click Invoke:

Set Focus: This function is used to give focus to the screen element. Select Set Focus in the Available Functions drop-down list, and click Invoke:

Refresh: This function destroys and then creates the captured physical object in the WPF application. Select Refresh in the Available Functions drop-down list, and click Invoke:

Set Property: This function sets a value of the specified property. To run this function, select Set Property in the Available Functions drop-down list and define the propName and propValue parameters:

propName: The name of the WPF object’s attribute. The value of this parameter is case sensitive.

propValue: The value of the WPF object’s attribute.

After you define the parameters of the function, click Invoke. The value of the requested property is displayed in the Returned Value field in Monitor.

Get Property: This function gets the value of a property by its name and function’s code. To run the function, select Get Property in the Available Functions drop-down list and then define the propName and funcCode parameters:

The value of the propName parameter is case sensitive.

funcCode parameter of Get Property function is an internal parameter. For any WPF object, the value must be 26.

After you define the parameters of the function, click Invoke. The value of the requested property is displayed in the Returned Value field in the Monitor.

Locate: To locate the selected WPF screen element in the WPF application, select the Locate function in the Available Functions drop-down list and click Invoke:

The element appears in a frame and a blinking red border in the WPF application:

Using Complex Functions

Below is an example of using complex functions that are listed for WPF screen element in the Functionality tab in Real Time Designer. These functions return results of CtrlPO, PO, and List of PO types.

Get Enumerator

Get Instance

Get Instance By Parent

Get Instances

Instances of CtrlPO type – every screen element that is not a Process screen element. Instances of PO type – every screen element (i.e., CtrlPO + Process).

The complex functions of other WPF screen elements can be created according to the examples a) – d) of such functions of the WPF General screen element below.

The following additional functions are available for definition of a WPF General screen element:

Get Enumerator function (returned type is CtrlPO)

This function returns the enumerating physical object. You can use it with every screen elemnet that its enumerator is a control (process is excluded because it doesn’t have an enumerator and usually top level window is excluded because its enumerator is the process).

Look at the Screen Elements tree in the image below. The enumerator of the WPF General screen element is Window – Simple Styles, which has WPF Window screen element type (as you can learn from the Main Relation Type):

Below is an example of a new function’s definition that calls the Get Enumerator function and then both locates the enumerator in the WPF application and returns Windows Handle’s value of this enumerator. As you know that the Get Enumerator function returns the enumerator of the WPF Window type, you can define the following by creating a new Business Entity Function of Number type in the Business Entity tab in Real-Time Designer. See Defining a Business Entity Function.

Next, you must assign the created function to a business entity property of Text type in order to retrieve the Text value, returned by the _Get Enumerator (Ctrl PO) function in our example. For this purpose, create another function (Get Enumerator - For Use) with assignment to the business entity property:

Place the Get Enumerator - For Use function into a Callout.

In runtime, call the function by clicking the function’s link. As a result, the enumerator of the WPF object is located and its Window Handle’s value is displayed in the callout:

Get Instance function (return type is PO)

This function returns the first recognized physical object of the screen element from the given process (input argument to this function is the Process ID). You can use it with every screen element.

Below is an example of a new function’s definition that calls the Get Instance function and then returns Windows Handle’s value t of this instance. As you know that this function returns the instance of WPF General, you can define the following by creating a new Business Entity Function of Number type in the Business Entity tab in Real-Time Designer. See Defining a Business Entity Function.

Next, you must assign the created function to the business entity property of Number type in order to retrieve the Window Handle’s value that the _Get Instance (PO) function returns. For this purpose create another new function (Get Instance - For Use) with assignment to the business entity property:

Place the Get Instance - For Use function into a Callout.

In runtime, you can call the function by clicking the function’s link. As a result, the Window Handle’s value of the WPF General instance is displayed in the callout.

Get Instance By Parent function (return type is PO)

This function returns the first recognized physical object of the screen element with a given enumerator (parent) Window Handle value (input argument to this function is the enumerator’s Window Handle). You can use it with all CtrlPO screen elements.

Look at the Screen Elements tree below. As you can see, the enumerator of the WPF General screen element is Window – Simple Styles, which has the WPF Window screen element type (as you can learn from the Main Relation Type):

Below is an example of a new function definition that calls the Get Instance By Parent function and then returns the Window Handle’s value of the WPF General screen element that this enumerator's window handle is an input argument.

As you know that the function returns the instance of the WPF General type, you can define the following example by creating a new Business Entity Function of Number type in the Business Entity tab in Real-Time Designer. See Defining a Business Entity Function.

Next, you must assign the created function to a business entity property of Number type in order to retrieve the Window Handle’s value, where _Get Instance By Parent (CtrlPO) function is returned in our example. For this purpose, create another new function (Get Instance By Parent - For use) and assign it to the business entity property:

Place the Get Instance By Parent - For use function into a Callout.

In runtime, call the function by clicking the function’s link. As result the Window Handle’s value of the WPF General instance is displayed in the callout.

Get Instances function (return type is List of PO)

This function returns all recognized physical object instances of the screen element (can be more than one, if multi instances). You can use it with every screen element.

Below is an example of a new function’s definition that calls the Get Instances function and then returns a list of Window Handles of all recognized instances of the WPF General objects (multi-instances).

As you know that this functions return the instance of WPF General type, then you can define the following by creating a new Business Entity Function of List of Number type in the Business Entity tab in Real-Time Designer. See Defining a Business Entity Function.

Next, you must assign the created function to a business entity property of Number type in order to retrieve the Window Handle’s value, the _Get instances (List of PO) function. For this purpose, create another new function (Get Instances - For use) and assign it to the business entity property:

Now you can place the Get instances - For use function into a Callout.

In runtime, you can call the function by clicking the function’s link. As a result, the Window Handle values of the WPF General instances are displayed in the Callout.