Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase number of clicks per second with pyautogui?

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!

like image 895
L_Pav Avatar asked Mar 04 '16 20:03

L_Pav


1 Answers

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.

like image 122
innoSPG Avatar answered Nov 12 '22 23:11

innoSPG