AttributeError: WindowSpecification class has no 'typekeys' method

AttributeError: WindowSpecification class has no 'typekeys' method

我是 Pywinauto 的新手,在登录远程桌面应用程序后尝试单击 "ENTER"。桌面 window 有一个带有 "OK" 按钮的使用免责声明,我可以按 "ENTER" 或鼠标移动来单击 "OK"。下面是代码片段和我得到的错误。

rem_app = Application(backend="uia").connect(title_re='.*Remote desktop.*')
dlg_rem = rem_app.window(title_re='.*Remote desktop.*')
dlg_rem.set_focus()
dlg_rem.typekeys('{ENTER}')

Error: Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\pywinauto\application.py", line 171, in call format(self.criteria[-1]['best_match'])) AttributeError: WindowSpecification class has no 'typekeys' method

我还通过查看其他相关的 Whosebug 问题使用了以下内容:

  1. keyboard.sendkeys('{ENTER}')
  2. dlg_rem.sendkeys('{ENTER}')

以下是 print_control_identifiers() 对 "OK" 按钮的描述。

   |    |    |    | Pane - ''    (L403, T360, R1671, B1320)
   |    |    |    | [u'3', 'Pane4']

   |    |    |    |    |
   |    |    |    |    | Pane - 'Input Capture Window'    (L403, T360, R1671, B1320)
   |    |    |    |    | [u'Input Capture Window', u'Input Capture WindowPane', 'Pane5']
   |    |    |    |    | child_window(title="Input Capture Window", control_type="Pane")

我想知道在上述两种情况下如何使用发送键和鼠标移动来单击"OK"。

正确的方法名称是 .type_keys('{ENTER}')。它在键入之前将焦点设置为目标 window。

如果您不需要自动对焦,只需使用 keyboard.SendKeys('{ENTER}') 而不绑定任何应用程序(0.6.3. 将具有符合 PEP8 指南的 keyboard.send_keys 别名)。

P.S。不建议通过远程桌面(使用任何工具)自动执行任何操作,因为 RDP 不会向本地计算机公开 UI 辅助功能。只需将脚本复制到远程机器,然后 运行 它就在那里。

如果您需要多台远程机器同时 运行ning GUI 自动化任务,请查看这些答案以获取更多详细信息: