【问题标题】:AttributeError: WindowSpecification class has no 'typekeys' methodAttributeError:WindowSpecification 类没有“typekeys”方法
【发布时间】:2017-06-05 13:08:28
【问题描述】:

我是 Pywinauto 的新手,登录远程桌面应用程序后尝试单击“ENTER”。桌面窗口有一个带有“确定”按钮的使用免责声明,我可以按“ENTER”或鼠标移动以单击“确定”。下面是代码 sn-p 和我得到的错误。

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}')

错误: Traceback(最近一次调用最后一次):文件“”,第 1 行,在文件中 “C:\Python27\lib\site-packages\pywinauto\application.py”,第 171 行,在 致电 format(self.criteria[-1]['best_match'])) AttributeError: WindowSpecification 类没有'typekeys'方法

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

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

下面是 print_control_identifiers() 对“确定”按钮的描述。

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

我想知道在上述两种情况下如何使用发送键和鼠标移动单击“确定”。

【问题讨论】:

    标签: pywinauto


    【解决方案1】:

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

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

    附:不建议通过远程桌面(使用任何工具)自动执行任何操作,因为 RDP 不会向本地计算机公开 UI 可访问性功能。只需将脚本复制到远程机器并在那里运行即可。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-21
      • 2020-12-24
      • 1970-01-01
      • 2015-04-06
      • 2013-01-19
      • 2021-09-27
      • 2015-11-22
      • 1970-01-01
      相关资源
      最近更新 更多