Exists property
- 6 years ago
I wouldn't use WaitProperty. WaitProperty is a method assigned to an object. So, when an object does not exist, calling that method will cause an error.
And that's the thing about the "Exists" property. You can't call the "Exists" property of an object that does not exist. If the object does not exist, it has no properties at all.
So... if you want to see if an item is on screen, you would use WaitChild or WaitAliasChild or something like that from the parent object.
Let's say, for example, we have the following.Aliases.MyApp
And after performing some sort of function I want to see if a form in that application exists, normally indicated by
Aliases.MyApp.MyForm
If it's a simple if-then, I'd do the following in JavaScript
if (Aliases.MyApp.WaitAliasChild('MyForm', 3000).Exists) { Log.Message('The form exists') } else { Log.Message('The form does not exist') }
This code will wait up to a maximum of 3 seconds for the object to exist. If it returns within 3 seconds, WaitAliasChild returns the actual object and Exists is true. If the 3 second limit is exceeded, WaitAliasChild returns a "stub" object with ONLY the Exist property set to false