Skip to content Skip to sidebar Skip to footer

Unable To Access Windows Controls Inside Pywinauto's Hwndwrapper (wrapper Class

I am new to python and pywinauto. Trying to set or get Text for TextBox (windows control) inside pywinauto.controls.hwndwrapper.hwndwrapper by using SWAPY, I have Class Name of wra

Solution 1:

pywinauto provides a 2-level concept based on WindowSpecification and wrappers. Window specification is just a description, set of criteria to search desired control (it may not exist when WindowSpecification is created). Concrete wrapper is created for really existing control if found. In IDLE console it looks so:

>>> app.RowListSampleApplication
<pywinauto.application.WindowSpecification object at 0x0000000003859B38>
>>> app.RowListSampleApplication.wrapper_object()
<pywinauto.controls.win32_controls.DialogWrapper object at 0x0000000004ADF780>

Window specification can have no more than 2 levels: app.WindowName.ControlName. It can be specified with more detailed search criteria:

app.window(title=u'SAP', class_name_re='^Afx:.*$')
app.SAP.child_window(class_name='Edit')

Possible window/child_window arguments are the same as listed in find_elements.


P.S. Great Python features can hide wrapper_object() method call in production code so you need to call it for debugging purpose only. For example these statements are equivalent (do the same):

app.WindowName.Edit.set_text(u'text')
app.WindowName.Edit.wrapper_object().set_text(u'text')

But the statements below return different objects:

app.WindowName.Edit # <WindowSpecification>
app.WindowName.Edit.wrapper_object() # <EditWrapper>

Post a Comment for "Unable To Access Windows Controls Inside Pywinauto's Hwndwrapper (wrapper Class"