riflosnake / HumanCursor

Simulate Human Cursor Movement for Automated Scripts
MIT License
84 stars 15 forks source link

Parameter to control speed? #2

Closed kijosenzo closed 1 year ago

kijosenzo commented 1 year ago

Hey there, really nice work on this. Very simple to set-up and use which was fantastic.

I was wondering if you plan on adding two parameters to cursor.move_to().

kijosenzo commented 1 year ago

Ah, I took the time to look at the source code and it already has duration. I modified cursor.move_to() duration (system cursor) to be a float because I need it to reach my target in around 0.1 seconds but it seems to have a minimum duration of around 1 second. What could be causing this?

Ex: cursor.move_to([450, 600], duration=0.1, steady=True)

riflosnake commented 1 year ago

Hey, thanks for reaching out!

Disabling the physical mouse is a great idea, I will research and probably find a way to implement it.

For the speed of the movement, its a bit complicated. The way the movement gets done, is by small incremental movements which reflect points of the graph curvature generated.

On the SystemCursor, it is already available as a parameter.

On the WebCursor, due to ActionChains Duration not properly working as intended for whatever reason (from my personal testing, let me know if i'm completely wrong), I have fine tweaked every parameter and randomization available, giving you the best result, but also taking your ability of customizing the movement sadly (unless you dig and manually change the parameters of the curve generator to check how each one of them reacts).

kijosenzo commented 1 year ago

Ah fast response! Sorry if I'm constantly editing this issue, I was and am in the middle of modifying and testing the code. As mentioned before I am only interested in system cursor for my use case at the moment. I looked at the source code and noticed you had set it to duration:int so I modified it to be duration:float. I do see drastic changes when I set it to be long like 10 seconds but for some reason, setting it below 1 second into milliseconds yielded no results.

What are your thoughts?

riflosnake commented 1 year ago

Ah fast response! Sorry if I'm constantly editing this issue, I was and am in the middle of modifying and testing the code. As mentioned before I am only interested in system cursor for my use case at the moment. I looked at the source code and noticed you had set it to duration:int so I modified it to be duration:float. I do see drastic changes when I set it to be long like 10 seconds but for some reason, setting it below 1 second into milliseconds yielded no results.

What are your thoughts?

My thoughts are that, I haven't checked and thought carefully about these details, and suspect that pyautogui.PAUSE and that small number don't really work nice together. But without getting my hands on and testing myself, I can't give you a definitive answer and solution. Tomorrow I think will give you a response. Be free to comment as many times as you want.

riflosnake commented 1 year ago

Just updated the package.

Now you should experience better and more fluent movement with your preferred duration. I also added duration to the drag_and_drop method and corrected other small things.

Blocking physical mouse input is not viable as of now for many reasons, but either way with my testing you can't actually interrupt the movement, only distort it a little bit if you actually want to. The cursor will reach the destination and every point it is plotted to.

Have a nice day!

kijosenzo commented 1 year ago

To be clear, duration is from the start of the cursor moving to its final destination right? I don't think I'm observing that behavior.