Event Control

Applies to TestComplete 15.69, last modified on November 13, 2024

The Event control is used to manage events that can be handled by TestComplete. This is an ActiveX control. It can be used either in TestComplete or in any other external application. The unique feature of this control is that you can modify the list of its events using the TestComplete Events project item. See Adding Events to Event Controls and Removing Events From Event Controls for more information.

The Event control includes the following methods:

AttachTo (Obj)

Attaches the Event control to the Obj object. Obj must implement the IDispatch interface. After the Event control has been attached, it can handle Obj events that are added to the control.

Note that if you are going to handle a COM application event that corresponds to a COM-server application (for instance, Microsoft Word or Outlook application), you should specify the application COM object rather than the TestComplete process object that corresponds to the desired program. For instance, in the case of Outlook, specify the Application object that is returned by the Sys.OleObject property or the getActiveXObject method:

JavaScript

var objOutlook;
...
objOutlook = getActiveXObject("Outlook.Application");
Events.GeneralEvents.AttachTo(objOutlook);
...

JScript

var objOutlook;
...
objOutlook = Sys.OleObject("Outlook.Application");
Events.GeneralEvents.AttachTo(objOutlook);
...

Python

objOutlook = Sys.OleObject["Outlook.Application"]
Events.GeneralEvents.AttachTo(objOutlook)

VBScript

Dim objOutlook
...
Set objOutlook = Sys.OleObject("Outlook.Application")
Events.GeneralEvents.AttachTo(objOutlook)
...

DelphiScript

var
  objOutlook : OleVariant;
begin
  ...
  objOutlook := Sys.OleObject('Outlook.Application');
  Events.GeneralEvents.AttachTo(objOutlook);
  ...
end;

C++Script, C#Script

var objOutlook;
...
objOutlook = Sys["OleObject"]("Outlook.Application");
Events["GeneralEvents"]["AttachTo"](objOutlook);
...

AttachToTestComplete

Used by Connected Applications to attach to the given Event control. After attaching to TestComplete, you will be able to handle TestComplete events that are added to the given Event control (for the full list of TestComplete events, see TestComplete Events).

DetachFromTestComplete

Used by Connected Applications to detach the given Event control from TestComplete. Note that after detaching from TestComplete, you will not be able to handle TestComplete events added to the Event control.

Note: The Event control only contains the AttachToTestComplete and DetachFromTestComplete methods if you added TestComplete events to the control.

See the following topics for more information on how to use these methods:

See Also

Handling Events
Handling Events - Overview
TestComplete Events

Highlight search results