Search code examples
pythonpywinauto

Missing control identifier - pywinauto


The print_control_identifier() function does not seem to list all the controls.

The window which I try to automate looks like this:

Edit field window

I'm trying to access the "plus" sign below the "Edit field" title. I can get the identifier of the bar where the 4 controls are added, but no childs of it. The bar itself is:

   | Toolbar - 'ToolBar'    (L1586, T836, R2254, B875)
   | ['ToolBar', 'ToolBarToolbar', 'Toolbar2']
   | child_window(title="ToolBar", class_name="TToolBar")

UPDATE: use of "UI Automation" mode

With Inspect I can get the following details of the toolbar and the "plus" sign.

Toolbar with Inspect Inspect toolbar

Button with Inspect Inspect button

Is there a way to access the control by ChildId as seen in details given by Inspect? Or some other way?

Backend is the default "win32". Changing it to "uia" did not reveal any more information.

Update: 2021-12-01

The following results to AttributeError.

buttons = app.EditField.child_window(title="ToolBar", class_name="TToolBar").buttons()

>>> AttributeError: Neither GUI element (wrapper) nor wrapper method 'buttons' were found (typo?)

Update 2021-12-02

The object itself doesn't return anything but print returns the following:

print(app.EditField.child_window(title="ToolBar", class_name="TToolBar").wrapper_object())
>>> common_controls.ToolbarWrapper - 'ToolBar', Toolbar

And the following returns:

print([w.window_text() for w in app.windows()])
>>> ['', 'Edit field', 'S100 - S10B9011DA', 'Progress', 'Enter numerical', '', 'xxxxxxx xxxxxxxx.scp - SICK CDS S100', 'CDS S100', '', .... '', 'DDE Server Window', '', 'M', 'Default IME']

The main window is the 'XXXX XXXX.scp - SICK CDS S100'. From there the window 'S100 - S10B9011DA' is opened, and from there you get access to 'Edit field'


Solution

  • OK, the correct methods for ToolbarWrapper are .button_count() and .button(0) as well as .texts() and .tip_texts(). See ToolbarWrapper docs for "win32" ToolbarWrapper.

    Method .button(0) or .button("Plus") (if this text is visible in .texts()) returns _toolbar_button object which has the following methods: see _toolbar_button docs.