1

In a python script, the response time for pyautogui.moveRel(b, a) is currently .1 sec. Is that the intended time for this function? If so, is there any way I can shorten this response time using another technique in python, or other languages? My goal response time is about 0.01 sec, which is the 60HZ rate.

Vandal
  • 903
  • 1
  • 14
  • 27
Mic
  • 33
  • 3

2 Answers2

2

The results @mertyildiran obtained are to be expected, since PyAutoGUI has a default 0.1 second pause between actions as a failsafe.

To speed things up, you can set the pause to a lower value, or even zero, like so:

pyautogui.PAUSE = 0
0

The code for checking the response time in microseconds(0.01 seconds = 10000 microseconds):

import pyautogui
import datetime

for x in range(0, 9):
    start = datetime.datetime.now()
    pyautogui.moveRel(None, 50)
    end = datetime.datetime.now()

    elapsed_time = end - start

    print elapsed_time.microseconds

Output:

269017
112927
113071
113061
112761
112561
113115
112107
112448

That means yeah it's approximately 0.1 seconds with this library and Python. So my recommendation is go with a deeper level programming language like C++.

Stimulate mouse event with C++ in Windows: https://stackoverflow.com/a/7492837/2104879

Stimulate mouse event with C++ in Linux: https://stackoverflow.com/a/8791599/2104879

Community
  • 1
  • 1
mertyildiran
  • 6,477
  • 5
  • 32
  • 55