I have been automating some mouse moving with pyautogui. Then I wanted the mouse to travel in a non linear path, so I started using humanclicker.
The issue im running into is that humanclicker has a 'minimum' travel duration. I want the travel times to be about 0.5 seconds because the buttons im clicking are right next to each other. However if i change the duration to any small number, the fastest the mouse will move with humanclicker function move() is 1.56 seconds... regardless of how far it has to move.
Here is my code:
import pyautogui,time
from pyclick import HumanClicker
hc = HumanClicker()
def test():
point_list = list(pyautogui.locateAllOnScreen('button.png', grayscale = True, confidence=.9))
for l in point_list:
point = pyautogui.center(l)
start = time.perf_counter()
hc.move((point[0],point[1]),duration=.000000000001)
finish = time.perf_counter()
print('finished in ',round(finish-start,2)," seconds")
test()
and my output:
finished in 1.64 seconds
finished in 1.58 seconds
finished in 1.58 seconds
finished in 1.56 seconds
finished in 1.58 seconds
finished in 1.57 seconds
finished in 1.59 seconds
finished in 1.56 seconds
finished in 1.56 seconds
if I change duration to sometime larger like 3 seconds, the travel time is around 3.19 seconds.
The confusing part is that my code was working find in terms for mouse travel time(i was getting fast 0.5 second clicks), but now suddenly its clicking slower as seen in the output.
update(next day):
Somehow i fixed it, not sure how.
I was tinkering with the pyclick package by calling
ctypes.windll.user32.SetCursorPos(int(point[0]),int(point[1]))
directly rather than through pyautogui, and concluded that it has to do with minimum sleep time of some sort, but couldn't fix it.
I then tried running the code in a VM and got the same slow speed.
Then went back to the original code and it ran fine magically...the duration parameter now applies correctly(if i ask for .5second duration, it runs at that speed)