Forum Discussion

mithileshmaurya's avatar
mithileshmaurya
Occasional Contributor
10 years ago

FindAllChildren

Hi

I am using Visual Studio IDE.My code is in c# .

Im accessing all objects through Connected apps.But when I use the below code:



textBoxes = w["FindAllChildren"]("WndClass", "Edit", 5);

  textBoxes = (new VBArray(textBoxes))["toArray"]();



It gives compiler error saying cannot resolve "VBArray" object .

What reference should I add so that the VBArray object  does not give me a compiler error.



Please help!

1 Reply

  • I don't think VBArray is supported in C# applications:




    Test complete script engine uses the Variant-array format that is not adopted in C#. So, to convert these values, you will have to call the UnWrap method of the var object.

     


     

     


    The following code demonstrates how you can call the FindAllChildren method from a C# Connected Application:

     

    void FindProcessMultiple()
    {
        // Creates arrays of properties and values
        String[] PropArray = new String[2];
        String[] ValuesArray = new String[2];
    
        // Specifies property names
        PropArray[0] = "ProcessName";
        PropArray[1] = "UserName";
    
        // Specifies the property values
        ValuesArray[0] = "*";
        ValuesArray[1] = Connect.Sys["UserName"];
    
        // Searches for the process
        var p = Connect.Sys;
        var res = p["FindAllChildren"](new var(PropArray), new var(ValuesArray), 1);
    
        // Posts the search results
        if (Connect.BuiltIn["VarArrayHighBound"](res, 1) >= 0)
        {
            object[] ManagedArray = (object[])res.UnWrap();
            for (int i = 0; i < ManagedArray.Length; i++)
            {
                var ArrayEntry = new var(ManagedArray);
                Connect.Log["Message"]("Found: " + ArrayEntry["ProcessName"].UnWrap());
           }
       }
        else
             Connect.Log["Message"]("Not found");
     }