How to increase number of clicks per second with pyautogui?

12,305

You can set pyautogui.PAUSE to control the duration of the delay between actions. By default, it is set to 0.1 sec, that is why you are getting at most 10 clicks per second.

pyautogui.PAUSE = 0.01

for example will reduce the delay to allow 100 clicks per second if your hardware supports it. From the doc, you can read the following:

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.

Share:
12,305

Related videos on Youtube

L_Pav
Author by

L_Pav

I absolutely love three things: chess, composition and programming. When I was 8, I started using scratch, and one day, when I was 13 (four years ago), I found out about python very strangely. I have been developing a snake game in scratch about a python who had to eat apples. As soon as I entered python game programming in Google, I found a link to pygame module. It was first necessary to install python. After I installed python, I found out about stacks overflow, but registered very recently. That is the story in a nutshell.

Updated on June 04, 2022

Comments

  • L_Pav
    L_Pav almost 2 years

    I am developing a bot for timed mouse clicking game. I am using pyautogui. The aim is to click most times on a button in a minute. My code is:

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

    The infinite loop is not the problem, since FAILSAFE will prevent any negative consequences (pyautogui.FAILSAFE() is by default set to True). Essentially the downside is, pyautogui can only reach up to 10 clicks per second. Does someone know if I can increase the number of clicks per second? And if yes, how? Advice will be greatly appreciated!

    • M7MD
      M7MD over 2 years
      Warning: Putting the delay 0 seconds will spam it until you can't stop it so try to make it at least 0.1 or you may delete your file or change in it when you try to stop it
  • L_Pav
    L_Pav about 8 years
    Thank you! I appreciate your help! :)
  • Al Sweigart
    Al Sweigart about 7 years
    You can even set pyautogui.PAUSE to 0.