Search code examples
pythonpython-3.xautomationui-automationpywinauto

How to read text from an 'Edit' class UI control using pywinauto?


pywinauto and in-general noob here. I am currently working on reading communication back from a robot arm in response to automated commands being sent to it using the terminal window inside the K-IDE program (Kawasaki IDE) using pywinauto. Using win32 in py_inspect I was able to identify the UI control containing the rich text that I want to access (marked with red arrow in screenshot). I want to save the rich_text property (marked in purple) of that UI control to a text file to parse it. How to use pywinauto to achieve this?

Thank you in advance :)

Screenshot: py_inspect_ss


Solution

  • It should look like this:

    from pywinauto import Application
    
    app = Application(backend="win32").connect(title_re='Trying to connect to "Standard 1".*', top_level_only=False)
    text = app.window(title_re='Trying to connect to "Standard 1".*', top_level_only=False).window_text()