gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 16:27:02 35 4
gpt4 key购买 nike

我正在开发一个用于定时鼠标点击游戏的机器人。我正在使用 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/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com