FormLostFocus Event

The Form and MDIChild controls contain a FormLostFocus event which lets you create projects which track the amount of time specific, interrogated Forms/MDIChild Windows were in focus (active) while a project was loaded in Runtime.  

The FormLostFocus event has a Duration argument which, when the event occurs, outputs the amount of time, in milliseconds, the Form/MDIChild was active prior to losing focus. The tally of the Duration value starts when the Form/MDIChild is shown or activated and ends when the form is deactivated or destroyed.

Note that a LostFocus event is also exposed for all targets. The two events are not directly related and the FormLostFocus event may not fire when the LostFocus event fires.  The FormLostFocus event provides a Duration argument to specify how long that form was active. The LostFocus event does not contain the Duration argument.

This topic describes:

 

When the FormLostFocus event occurs

The FormLostFocus occurs when:

 

Accessing the duration value

When the FormLostFocus event occurs, a duration value is calculated and output as the FormLostFocus Duration event argument (Int32 type). OpenSpan tallies the amount of time, in milliseconds, during which the Form/MDIChild was in active prior to losing focus. The connection block below shows the Duration event argument.

 

Using the FormLostFocus event in a sample automation

The following automation shows using the FormLostFocus event and storing the Duration values in a table:

Note: The FormLostFocus event can and does occur after a Form has been destroyed (closed, application shutdown, and so on).  Do not use the FormLostFocus event to access certain properties or to call methods on the form or its child controls since the Form and its controls may no longer be matched when the event occurs.

If you require using the FormLostFocus event to access properties or call methods for a form and/or its child controls, surround the execution path with Try/Catch blocks to catch any exceptions that may occur.

 

Capturing Form and Child Window Title with FormLostFocus

An additional value to the Event block lets you capture the form or child window title text as the FormLostFocus event fires.

 

How to Use the FormLostFocus Event with OpenSpan's Events Feature

You can use Generic and Custom event notifications with the Events feature to monitor Form and MDI Child window activity. These steps describe using the FormLostFocus event in a Generic events project.

  1. Add the web or Windows adapter and set the StartPage or Path property.

  2. Start Interrogation and interrogate at least one target in the application and then Stop Interrogation.

  3. Set the MonitoredEventsMode property for the adapter to either All Controls or Interrogated Controls.

  4. Browse the MonitoredEvents property and select Form and/or MDI Child under Target Type and FormLostFocus under Events on the Configure Monitored Events window.

  5. Add and configure the EventServiceWebServiceConnector component to distribute events to the event notification service.

While running the project, event notifications are triggered when the Form/MDIChild focus changes as described in the When the FormLostFocus event occurs section of this topic. The Duration value is calculated and sent with the FormLostFocus event notification data.

 


Privacy | Trademarks | Terms of Use | Feedback

Updated: 18 June 2020

© 2016 - 2020 Pegasystems Inc.  Cambridge, MA All rights reserved.

 

OpenSpan data classification label