Search code examples
pythonpywinauto

How do I select item from list using Pywinauto


Hi I have a Gui that I open with pywinauto and what I would like is to select in Item from a list inside a window and click in that list now I can open the gui with this code

 for element in os.listdir(direction):
         if element.endswith('Nasfla'):



             path2=''.join((direction,'\\',element))
             for exe  in os.listdir(path2) :
                 if exe.endswith('flagui90.exe'):
                     path3=''.join((path2,'\\',exe))
             app = Application()
             #opining nasgro
             app.start(path3)
             #open second window
             app.NASFLACrackGrowthAnalysis.Showcrackcaselibrary.click()
             # try to select item from list but not working 
             app.CrackCaseLibrary.ThroughCracks.click

please see pictures to undrestand the Yellow is what i would like to selectenter image description here


Solution

  • I found out how to do it so for people who are using pywinauto

    app.NASFLACrackGrowthAnalysis.Showcrackcaselibrary.click()
    app.CrackCaseLibrary.ListBox.select(0)
    

    ListBox allow you to get the list from GUI and the .select() take index of item