Description
Generates an event specified by its name for the given tested object. The list of available events is displayed in the Events pane of the Object Browser panel. If the event handler requires one or more parameters, then they should be specified after the EventName parameter.
Declaration
aqObject.RaiseEvent(IObject, EventName, Param1, Param2, ...)
IObject | [in] | Required | Variant | |
EventName | [in] | Required | String | |
Param1 | [in] | Optional | Variant | |
Param2 | [in] | Optional | Variant | ... |
Result | Boolean |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
IObject
The object whose event you want to generate.
EventName
The name of the event to be generated.
If the event with the given name was not found, an error occurs. Use the aqObject.IsSupported
method to verify whether the object has a certain event.
Specify the parameters (if any) required by the event handler.
Result Value
True if the event has been generated successfully, and False otherwise.
Remarks
The RaiseEvent
function does not support HTML objects.
Since RaiseEvent
is a reserved keyword in VBScript, to call the RaiseEvent
function in VBScript code, you must place the aqObject
object name before the function name: aqObject.RaiseEvent
. Otherwise, you will get a VBScript compilation error when running the script.
Example
The code below checks whether the specified event is supported by the object. If it is, the routine raises the event. Otherwise, an error occurs.
JavaScript, JScript
function RaiseEventExample()
{
// Specifies the object and the event name
var Obj = Sys.Process("MyApplication");
var sName = "EventName";
// Checks whether the needed event is supported by the object
if ( aqObject.IsSupported(Obj, sName) )
// Raises the event
aqObject.RaiseEvent(Obj, sName)
else
Log.Error("The specified event is not supported by the object");
}
Python
def RaiseEventExample():
# Specifies the object and the event name
Obj = Sys.Process("MyApplication")
sName = "EventName"
# Checks whether the needed event is supported by the object
if aqObject.IsSupported(Obj, sName):
# Raises the event
aqObject.RaiseEvent(Obj, sName)
else:
Log.Error("The specified event is not supported by the object")
VBScript
Sub RaiseEventExample
' Specifies the object and the event name
Set Obj = Sys.Process("MyApplication")
sName = "EventName"
' Checks whether the needed event is supported by the object
If aqObject.IsSupported(Obj, sName) Then
' Raises the event
Call aqObject.RaiseEvent(Obj, sName)
Else
Log.Error "The specified event is not supported by the object"
End If
End Sub
DelphiScript
function RaiseEventExample;
var Obj, sName;
begin
// Specifies the object and the event name
Obj := Sys.Process('MyApplication');
sName := 'EventName';
// Checks whether the needed event is supported by the object
if ( aqObject.IsSupported(Obj, sName) ) then
// Raises the event
aqObject.RaiseEvent(Obj, sName)
else
Log.Error('The specified event is not supported by the object');
end;
C++Script, C#Script
function RaiseEventExample()
{
// Specifies the object and the event name
var Obj = Sys["Process"]("MyApplication");
var sName = "EventName";
// Checks whether the needed event is supported by the object
if ( aqObject["IsSupported"](Obj, sName) )
// Raises the event
aqObject["RaiseEvent"](Obj, sName)
else
Log["Error"]("The specified event is not supported by the object");
}
See Also
Handling Events
GetPropertyValue Method
SetPropertyValue Method
CallMethod Method
IsSupported Method