Fix memory corruption, thread safety, and click randomization#131
Fix memory corruption, thread safety, and click randomization#131a8kj7sea wants to merge 1 commit intorobiot:masterfrom
Conversation
…the receiving thread
| else | ||
| { | ||
| int micro_variance = (rand() % 10000) - 5000; | ||
| int final_sleep = sleep + micro_variance; |
There was a problem hiding this comment.
whats the point of having a micro variance on the non random interval?
If a user sets a specific interval, we'd ideally not want to add randomization to it?
There was a problem hiding this comment.
Regarding the variance question: Without it, the timing is perfectly robotic (e.g., 100ms, 100ms, 100ms). Adding that tiny jitter makes the clicks look human and harder to detect as a script.
There was a problem hiding this comment.
But that's why we have the randomization option, where you can randomize it.
Some people might want it to be as perfect as possible, and I dont think we should force the jitter.
You get what I mean?
| if (click(display, args->button, using_xevent, hold_type_ms) == FALSE) | ||
| xapp_error("Sending click", -1); | ||
|
|
||
| int double_click_delay = 150000 + (rand() % 20000); |
There was a problem hiding this comment.
It is a process used in several applications to simulate human behavior. This fluctuation is useful in various applications, including simulating screen taps with human-like behavior to ensure the script is not detected or caught.
This update addresses a few stability issues I noticed, specifically around memory management and how the clicking thread communicates with the UI. I also took the opportunity to make the clicking behavior feel a bit more natural.
What’s New:
Fixed Crashes: Resolved a memory corruption issue when updating cursor positions. By moving the memory-freeing logic into the receiving thread, the app is now much more stable when rapidly capturing coordinates.
Better Thread Sync: Switched the
isClickingflag to use atomic operations. This ensures that starting and stopping the clicker is thread-safe and prevents potential race conditions.More Natural Clicking: * Added micro-variance to the sleep intervals so the timing isn't perfectly robotic.
Introduced a slight random delay between double-clicks.
Improved the random seeding so each session feels unique.
Code Cleanup: Refactored the core click handler and hotkey logic to make the code easier to read and maintain moving forward.
Overall, these changes should make the tool feel smoother and much more reliable during long sessions.