I'm using pywinauto to automation Click on some button on DiffDaff software.
My intention are:
Step 1: Open DiffDaff software
Step 2: Click 'About' button
from pywinauto.application import Application
app = Application.start("C:\Program Files\DiffDaff\DiffDaff.exe")
app.About.Click()
But, I'm on stuck at step 2, and the console show error:
File "build\bdist.win32\egg\pywinauto\application.py", line 238, in __getattr__
File "build\bdist.win32\egg\pywinauto\application.py", line 788, in _resolve_control
pywinauto.findbestmatch.MatchError: Could not find 'About' in '['', u'DiffDaff - Compare Files, Folders And Web Pages', u'Internet Explorer_Hidden', u'DiffDaff - Compare Files, Folders And Web PagesDialog', 'Dialog']'
Where, '', u'DiffDaff - Compare Files, Folders And Web Pages', u'Internet Explorer_Hidden', u'DiffDaff - Compare Files, Folders And Web PagesDialog', 'Dialog' is the title of sotfware
Also, using the command 'app.dialogs.print_control_identifiers()'
to know what exact position of 'About' button, there is the output:
Button - '&About' (L750, T388, R834, B411)
'&About' '&AboutButton' 'Button3'
But it's so difficult to understand the parameter as above (what/where is L750, T388,...) - Would you like to explain all the mean of parameters as above ?
And the way to perform 'Click' button ?
Thanks.
pywinauto
requires 2-level hierarchy from Application object to control method. The structure of any call is
app.<DialogName>.<ControlName>.<method>(<params>)
In your case it should look like
app.Dialog.About.click()
If you need more realistic click, please use click_input()
which moves cursor and clicks the control as user. click()
only sends WM_CLICK
and it's less reliable also.
print_control_identifiers()
method prints the following information:
<ControlType> - '<Name a la WindowText>' (<rectangle>)
possible names which are most likely useful for object attribute access
Mentioned code is equivalent to the following:
app.window(best_match='Dialog', top_level_only=True).child_window(best_match='About').click()
pywinauto
simplifies such constructions by overriding __getattribute__
method.