使用pywinauto单击对话框的取消按钮

时间:2018-06-20 20:47:13

标签: python windows pywinauto

我遇到的一种情况是,如果将受密码保护的.ppt文件传递给PowerPoint,则PowerPoint的自动化过程会挂起。我使用pywinauto编写了一个脚本来检测何时发生这种情况,并连接到“密码”对话框,但单击“取消”按钮似乎找不到它。

这是我在“输入密码”对话框中看到的控件标识符:

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")

我尝试做password_dialog.NetUICtrlNotifySink.Click(),但是什么也没发生。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我建议对所有MS Office产品使用Application(backend="uia")。它应该看到更多控件。