Search code examples
pywinauto

Getting window parameters with pywinauto (Top,Bottom,Right,Left)


Getting window parameters with pywinauto (Top,Bottom,Right,Left) I've managed to get these valuses using the following snippet of

PrintControlIdentifiers()

Taken from this documentation page on their github. https://pywinauto.github.io/docs/code/pywinauto.application.html#pywinauto.application.WindowSpecification.PrintControlIdentifiers

It does not quite do what I want it to do, it looks for an element in the application I am running. (The control identifier) and gives me the location for it on screen, using the following parameters.

(Top,Bottom,Right,Left)

My question is simple. Is there a function that works on a higher level, that dosen't go into elements of the window, but instead just prints the (Top,Bottom,Right,Left) value for the window you've opened and not it's elements.


Solution

  • Just use .Rectangle() method and print its return value.

    To get the hint on the list of available methods (in interactive mode) method .WrapperObject() is useful (in production it's called implicitly). Say you have

    dlg = app.DialogName.WrapperObject()
    

    Then you're able to type dlg. in IPython/IDLE/python.exe and get the list of available methods/properties for the window. Or just use print(dir(dlg)).