-1

In our SAP System, we automate the GuiTree control quite often, via SAP GUI Scripting API. In the left column, there is a Description. In the second column, there is an icon containing a tooltip.

enter image description here

With this code, I can read the text of each node:

        /*ID is the SAPFEWSELib.GuiComponent.Id of the SAPFEWSELib.GuiTree; SAPWindow is the mainwindow 
        of SAP of type SAPFEWSELib.GuiMainWindow*/
        SAPFEWSELib.GuiTree GT = (SAPFEWSELib.GuiTree)SAPWindow.FindById(ID);
        foreach (string key in GT.GetAllNodeKeys())
        {
            System.Console.WriteLine("Key " + key + " contains " + GT.GetNodeTextByKey(key));
        }

Is there a possibility to access the second column too?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Jan021981
  • 521
  • 3
  • 28

1 Answers1

0

Ok, I found it out, it's the method GetItemText(key, "1") where key is the node ID and 1 is the column index for the first column.

If the item is checked, the icon has a tooltip.

System.Collection.Generic.List<System.Collection.Generic.KeyValuePair<string, bool>> MyList = new System.Collection.Generic.List<System.Collection.Generic.KeyValuePair<string, bool>>();
string NodeText = string.Empty;
bool = TextExist = false;
SAPFEWSELib.GuiTree GT = (SAPFEWSELib.GuiTree)SAPWindow.FindById(ID);
foreach(string key in GT.GetAllNodeKeys()){
     NodeText = GT.GetItemText(key, "1"); //1 is the column index, starts with 1
     if(GT.GetItemText(key, "2").Length > 0){TextExist = true;}else{TextExist = false;}
     MyList.Add(new System.Collection.Generic.KeyValuePair(NodeText, TextExist);   
}

I hope this will help other developers.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Jan021981
  • 521
  • 3
  • 28
  • You may find the official SAP documentation on the members of the `GuiTree` objects [here](https://help.sap.com/viewer/product/sap_gui_for_windows/760.02/en-US?q=GuiTree+Object). – Sandra Rossi May 19 '20 at 12:07