Search code examples
pywinauto

How to get a window specification from a wrapper?


I have a wrapper of an element which is not always enabled or visible so I want to wait for it. To do it, I have to get the window specification of this wrapper in order to do:

window_specification.wait("exists enabled visible ready")

How to implement the following function?

window_specification = get_window_specification(wrapper)

Solution

  • This is currently not implemented natively in pywinauto. But it can be created like this:

    spec = app.window(handle=wrapper.handle, top_level_only=False)
    

    In next major release we're planning to add waiting for specific state in wrapper object. So finding wrappers and waiting for state will be different options.

    In current version (pywinauto==0.6.8) there is one more way: wait_until and wait_until_passes functions from module timings. It adds flexible waiting for any condition.