The code that I' using.
The object that I want to wait for is for example a gui- object:
CheckIfApplicationStarted("AWTComponentName","Whatever",Sys.Process("java").SwingObject.AndSoOn.AndSoOn)
function CheckIfApplicationStarted(str_PropertyName,str_PropertyValue,obj_BaseObject,int_TimeoutInSeconds){
try{
var obj_Result = Utils.CreateStubObject();
var int_TimeoutForRetrys = 10
if(int_TimeoutInSeconds != undefined){
int_TimeoutForRetrys = int_TimeoutInSeconds
}
for(var i = 0 ; i< int_TimeoutForRetrys; i++){
obj_BaseObject.Refresh()
obj_Result = FindObjectInBaseObject(str_PropertyName,str_PropertyValue,obj_BaseObject,2)
if(obj_Result.Exists){
Log.Message("Propertyvalue '" +str_PropertyValue+ "' for property in object '" +str_PropertyName+ "' found")
return obj_Result
}
else{
Log.Message("Wait for object...")
}
Delay(1000)
}
return obj_Result
}
catch(e){
Log.Error("Error while check property: " +e.message)
}
}
function FindObjectInBaseObject(str_PropertyName,str_PropertyValue,obj_BaseObject,int_Depth){
var obj = Utils.CreateStubObject();
var int_SearchDepth = 50
if(int_Depth != undefined){
int_SearchDepth = int_Depth
}
try{
if(str_PropertyName === undefined || str_PropertyValue === undefined){
Log.Message("No property value or propertyname passed")
return obj
}
var obj = obj_BaseObject.Find(str_PropertyName,str_PropertyValue,int_SearchDepth)
if(obj.Exists){
Log.Message("Found object: " +obj.Name)
}
else{
Log.Message("No object found with the propertyname '" +str_PropertyName+ " and the property value '" +str_PropertyValue+ "'")
}
}
catch(e){
Log.Error("Error while trying to find object: " +e.Message)
}
return obj
}