python - 如何使用 pyautogui 增加每秒的点击次数?

标签 python python-3.x pyautogui

我正在开发一个用于定时鼠标点击游戏的机器人。我正在使用 pyautogui。目标是在一分钟内点击按钮的次数最多。我的代码是:

import pyautogui, time
time.sleep(5)
while True:
    pyautogui.click()

无限循环不是问题,因为 FAILSAFE 会防止任何负面后果(pyautogui.FAILSAFE() 默认设置为 True)。本质上的缺点是,pyautogui 每秒最多只能达到 10 次点击。有人知道我是否可以增加每秒的点击次数吗?如果是,怎么办?非常感谢您的建议!

最佳答案

您可以设置pyautogui.PAUSE 来控制 Action 之间延迟的持续时间。默认情况下,它设置为 0.1 秒,这就是您每秒最多获得 10 次点击的原因。

pyautogui.PAUSE = 0.01

例如,如果您的硬件支持,将减少延迟以允许每秒 100 次点击。 来自doc ,您可以阅读以下内容:

You can add delays after all of PyAutoGUI’s functions by setting the pyautogui.PAUSE variable to a float or integer value of the number of seconds to pause. By default, the pause is set to 0.1 seconds.

关于python - 如何使用 pyautogui 增加每秒的点击次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35805649/

相关文章:

python - sqlalchemy.exc.InvalidRequestError : Can't attach instance another instance with key is already present in this session

python - 从 numpy 结构化数组中的数据打印行

python - 在Python中加载和播放音乐

python-3.x - discord bot -- IndexError : list index out of range

python - 如何在pyautogui中点击图像中心

python-3.4 - 在不同分辨率的不同计算机上运行 Pyautogui

python - Pyautogui - 需要按住 shift 键并单击

python - 我的 mod_wsgi Web 应用程序没有运行其他脚本

python - 带有 Flask 应用程序的 uwsgi 给出 "callable not found or import error"

python-3.x - 从 Python 中的区间生成随机数