Forum Discussion

najes's avatar
najes
Occasional Contributor
7 years ago

passing variables on FindChild

Is it possible to pass variables on FindChild methods?
For example (in Jscript):

var parent = Aliases.Program.MainWindow;
var child = new Array(100);

for(var i =0; i<100; i++)
{
  child[i] = parent.FindChild( ["WndClass", "Index"], ["Button", i], 2, true);
}


Been trying to get the state of each object child[i].wState, but it seems like it always fail to get the object.

    • najes's avatar
      najes
      Occasional Contributor

      I have tried to use the FindAllChildren method, however it's too hard for me to use because on the window that i test consist of a lot of check boxes and radio buttons. The object properties i can use to limit the search is only the WndCaption and WndClass.

      Or do you have any other suggestion of technique i can use? My current test purposes is to make sure all these check boxes and radio buttons always work properly.

  • najes's avatar
    najes
    Occasional Contributor

    Thank you for your reply, will!


    However the objects that i want to map do have wState.


    I tried to use the method as follow: 

    child[i] = parent.FindChild( ["WndClass", "Index"], ["Button", 45], 2, true).wState;

    And it's working, however if i change the index 45 to the i variables, i got the error: "Unable to find the object wState. See Additional Information for details."

  • Do you KNOW you have 45 children?  There should be a child count property (or something named very similarly) on the parent object, which you can use as the upper limit in your loop.

    • najes's avatar
      najes
      Occasional Contributor

      That is one of the object button, I got the value 45 which is the property value of the property name "Index" using the Object Spy.


      So in this case there're a lot of check boxes and radio buttons (there are like hundreds of them) that arranged in rows and columns.


      One of the test case is that I need to make the testing for each desired rows only.


      Using the Object Spy, i figured that the property value of the property name "Index" of  the buttons in the same row is in sequence (for example in row 5, there are 9 buttons with the property value of the property name "Index" are: 37,38,39,40,41,42,43,44,45).


      Therefore I plan to use loop with FindChild to taking care of the mapping, but the loop i made before is not working.