Forum Discussion

yaacovk's avatar
yaacovk
Contributor
10 years ago

Find method- Is it possible to define property to be different than a specific value

Hi,

 

I want to use the FindChild method but 1 of required properties is not known.

I only know that this property have to be greater than a specfic value.

For example, I want to use a script like this:

(jscript)

var x = <value>;

var PropArr = new Array("Visible",  "ScreenLeft");

var ValArr = new Array(true, !x);

var child = wnd.FindChild(PropArr, ValArr, 15);

 

As described I need to find the child that its ScreenLeft property is greater that x.

Currently, I don't get the expected child.

Can you help?

 

  • Since you can't really define that type of property, seems like you would be better served defining the WndClass and Visible properties and using the FindAllChildren, then iterate the collection that is returned evaluating for the control with the ScreenLeft property value meets the required criteria:

    var x = <value>;
    var wndClass = "WindowClassName";
    var props = new Array("WndClass", "Visible");
    var values = new Array(wndClass, True);
    var ctrls = wnd.FindAllChildren(props, values, 15);
    
    for (var i = 0; i < ctrls.length; i++)
    	if ()ctrls[i].ScreenLeft > x) {
    		Log.Message("FullName: " + ctrls[i].FullName + "\r\n" +
    						"ScreenLeft: " + ctrls[i].ScreenLeft);	
    	}
    }
  • Since you can't really define that type of property, seems like you would be better served defining the WndClass and Visible properties and using the FindAllChildren, then iterate the collection that is returned evaluating for the control with the ScreenLeft property value meets the required criteria:

    var x = <value>;
    var wndClass = "WindowClassName";
    var props = new Array("WndClass", "Visible");
    var values = new Array(wndClass, True);
    var ctrls = wnd.FindAllChildren(props, values, 15);
    
    for (var i = 0; i < ctrls.length; i++)
    	if ()ctrls[i].ScreenLeft > x) {
    		Log.Message("FullName: " + ctrls[i].FullName + "\r\n" +
    						"ScreenLeft: " + ctrls[i].ScreenLeft);	
    	}
    }