开发者

pywinauto: taking more than one app windows

I have a GUI application which can create many similar windows on desktop. All windows have same title. I have to enumerate all dialogs with same title and make some tests against each of such dialogs.

If I call:

dialog = app['Window Name']

pywinauto returns a WindowSpecification object which is useful along with accessing controls by name.

When I call:

dialogs = app.windows_(title='Window Name')

pywinauto returns me a list of HwndWrapper instances which are not so useful.

How to obtain a开发者_如何学运维 list of windows with specified title but as WindowSpecification objects?


You can't really. WindowSpecification is a single specification for all windows that match the criteria supplied. When you work with a WindowSpecification instance you are often interacting with an HwndWrapper instance that WindowSpecification is finding and accessing for you.

So I think the answer is to work with the HwndWrapper's returned by app.windows_() (similar to the single HwndWrapper returned by WindowSpecification.WrapperObject()

Note - if you are always trying to narrow down the list of windows by looking at particular controls within a window - then using app['Window Name']['Unique Control Name'].Parent() should return the window.

The main difference between WindowSpecification and HwndWrapper is that a WindowSpecification does not have to exist yet, while a HwndWrapper instance reflects a particular underlying windows handle. This allows WindowSpecification to implement code that waits for windows or checks if they exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜