0

I'm trying to develop a solver for good ole' Minesweeper, but running into a hitch.

Environment: I setup Python 3.4.6 (x64) and am using Pywinauto 0.61 and the old Windows 7 Minesweeper from Winaero's "Windows 7 games for Windows 10".

Problem: I can't seem to detect dialog items nor interact with them using Pywinauto, yet I can tell from inspect they are clearly there.

1) Minesweeper

2) Inspect.exe showing the process ID - which matches pywinauto's - and all relevant children

3) Results of Print_Control_Identifiers() on the window and the child. Lacking the children shown in 2)

My code is as such:

app = pywinauto.Application().connect(class_name="Minesweeper")
mswpr = app.window(title="Minesweeper")
mswpr.print_control_identifiers()
mswpr.child_window().print_control_identifiers()

After fiddling with this for hours, I'm still not sure what I'm missing. I expect to see a list of groups, a menu bar, and a title bar to appear in one of the outputs (given inspect's results): acknowledging they are recognized by pywinauto, yet I'm given nothing. I am sure the program is locating the right process and window, given the process ID and window dimensions match between inspect and pywinauto.

Suspicions: The first is that this, being a Microsoft product, is simply inaccessible through the traditional means of Pywinauto. Another idea is that I see conflicting UIA and win32 types, alternating between backends in Pywinauto yielded nothing. I've also attempted to directly access dialogs by name with the code I was able to determine via inspect.exe to no success. My question is, what could I be missing?

Thank you for any clues or suggestions.

  • Your code is using default "win32" backend. But `Inspect.exe` uses UI Automation technology (mapping to `backend="uia"` when creating `Application(backend="uia")`). Default "win32" backend is mapped to Spy++. All Universal Windows Apps (UWP) are UIA compatible only. – Vasily Ryabov Dec 13 '17 at 18:39
  • Vasily - You're completely right, I swear I checked it multiple times.... hmm. Any idea why I would be getting horrendously slow times for almost any action on my project? There are ~600 controls on the window, is this known to be incredibly slow with UIA3 or with pywin's wrapping? – Lou Bernardi Dec 15 '17 at 19:39
  • UIA might be slow itself. But handling so many controls is also a problem for current pywinauto implementation. For example, iTunes has up to 3K controls which is a nightmare for method `print_control_identifiers()`. But searching some single control could be speed up using several tricks like `control_type` or `depth` keywords in `.child_window` criteria. – Vasily Ryabov Dec 17 '17 at 15:46

0 Answers0