【问题标题】:Simulate text input on mac using python使用python在mac上模拟文本输入
【发布时间】:2017-04-25 10:48:12
【问题描述】:

我有一个打开的 word 文档,并且我已经构建了一些可以自动单击并打开它的东西。现在,我想编写一个 python 程序,执行时会在文档中输入“Hello”。我该怎么做?

【问题讨论】:

  • 在 Python 中编写文本文档并让 Word 打开它可能更容易......
  • 我同意——最终的产品是尝试在画笔中自动绘制图片(包括文本),但我想先让它在 word 中工作。
  • 可能会使用类似sikuli

标签: python macos text terminal keyboard


【解决方案1】:

你试过PyAutoGUI吗?

import pyautogui
pyautogui.typewrite('Hello world!\n', interval=secs_between_keys)  # useful for entering text, newline is Enter

【讨论】:

    【解决方案2】:

    我使用https://pypi.python.org/pypi/PyUserInput/ 并通过导入解决了我的问题

    从 pymouse 导入 PyMouse 从 pykeyboard 导入 PyKeyboard

    【讨论】:

      猜你喜欢
      • 2012-07-02
      • 2013-09-29
      • 2014-09-03
      • 1970-01-01
      • 2017-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多