BlueM / cliclick

macOS CLI tool for emulating mouse and keyboard events
https://www.bluem.net
Other
1.62k stars 122 forks source link

How can I change the default delay to 20ns instead of 20ms? #84

Closed whimsica closed 6 years ago

whimsica commented 6 years ago

I tried changing waitingTime.nsec to 0 everywhere but it didn't seem to have an effect. How can I set the delay to 20 nanoseconds instead of milliseconds.

BlueM commented 6 years ago

This should not require anything except changing waitingtime.tv_nsec to 20. How did you verify that it does not work as expected? What exact command where you executing?

whimsica commented 6 years ago

Hi. Thank you for building cliclick! I am executing 100 c# process commands in a row to move 1 pixel at a time across a screen from 0,0 to 100,100. I set the waitingtime.tv_nsec to 20 everywhere and sec to 0 wherever I found it. Seems to move the same speed which takes about 1 second to move 100 pixels. Originally I put cliclick in the usr/local/bin ran xcode and the replaced it with the new one. Is that okay? Will one mouse move from 0,0 to 100,100 cross 50,50 or will it just jump to 100,100?

BlueM commented 6 years ago

I wonder what is the purpose of your series of commands? Do you want to move the mouse more slowly? If yes, you’re probably better off using the -e (“easing”) option, for instance like this:

cliclick -e 500 m:0,0 m:100,100

Of course you can move a build to /usr/local/bin, but this is just too tedious. You can either invoke the full path to your build (/path/to/where/build/is/cliclick) or change the PATH for your terminal session:

export PATH="/path/to/directory/containing/cliclick:$PATH"

When not using -e, the mouse will not cross 50,50 as it will be just 1 event. If you use -e, there will be a whole bunch of events (depending on the distance), and at least one of them will probably be very near to 50,50, but this cannot be predicted.

whimsica commented 6 years ago

Thanks for the clarification and path fix. Actually I'm trying to move the mouse as fast as possible at every possible pixel in the rectangle from 0,0 to 100,100.

BlueM commented 6 years ago

Then running cliclick m:0,0 m:0,1 m:0,2 m:0,3 ... with a custom-build binary with waitingtime.tv_nsec reduced should theoretically really be probably the way to go. No idea why it doesn’t work in your case.

whimsica commented 6 years ago

I created the command as you suggested with my c# program and then ran it through the process. It takes about 3 seconds to scan the 10,000 pixels. I also pasted the command into the command line directly with the same result. Shouldn't it be about 200 ms. Is there some other osx system factor that also limits the mouse speed?

BlueM commented 6 years ago

I have no idea. But from my work on cliclick I can say: the code contains arbitrary delays because it often would work too fast for the OS to register the events. So even if it worked as fast as your’re trying to run it, I’d not assume that the outcome is as you expect.