Nick Gotch
Nick Gotch

Reputation: 9407

Using pywinauto to click dialog box Cancel button

I have a situation where an automation process for PowerPoint gets hung up if a password protected .ppt file is passed into it. I've worked out a script to detect when this happens using pywinauto and hook up to the Password dialog but I can't seem to get it to click the Cancel button.

Here's the control identifiers I see for the Enter Password dialog:

NUIDialog - 'Password'    (L649, T422, R999, B553)
['NUIDialog', 'Password', 'PasswordNUIDialog']
child_window(title="Password", class_name="NUIDialog")
   |
   | NetUIHWND - ''    (L657, T453, R991, B545)
   | ['NetUIHWND', 'PasswordNetUIHWND']
   | child_window(class_name="NetUIHWND")
   |    |
   |    | NetUICtrlNotifySink - ''    (L728, T495, R983, B510)
   |    | ['PasswordNetUICtrlNotifySink', 'NetUICtrlNotifySink']
   |    | child_window(class_name="NetUICtrlNotifySink")
   |    |    |
   |    |    | RICHEDIT60W - ''    (L728, T495, R983, B510)
   |    |    | ['PasswordRICHEDIT60W', 'RICHEDIT60W']
   |    |    | child_window(class_name="RICHEDIT60W")
   |    |
   |    | RICHEDIT60W - ''    (L728, T495, R983, B510)
   |    | ['PasswordRICHEDIT60W', 'RICHEDIT60W']
   |    | child_window(class_name="RICHEDIT60W")
   |
   | NetUICtrlNotifySink - ''    (L728, T495, R983, B510)
   | ['PasswordNetUICtrlNotifySink', 'NetUICtrlNotifySink']
   | child_window(class_name="NetUICtrlNotifySink")
   |    |
   |    | RICHEDIT60W - ''    (L728, T495, R983, B510)
   |    | ['PasswordRICHEDIT60W', 'RICHEDIT60W']
   |    | child_window(class_name="RICHEDIT60W")
   |
   | RICHEDIT60W - ''    (L728, T495, R983, B510)
   | ['PasswordRICHEDIT60W', 'RICHEDIT60W']
   | child_window(class_name="RICHEDIT60W")

I tried doing a password_dialog.NetUICtrlNotifySink.Click() but nothing happens. Any ideas?

Upvotes: 1

Views: 833

Answers (1)

Vasily Ryabov
Vasily Ryabov

Reputation: 9991

I would recommend using Application(backend="uia") for all MS Office products. It should see much more controls.

Upvotes: 3

Related Questions