Skip to content

Fix memory corruption, thread safety, and click randomization#131

Open
a8kj7sea wants to merge 1 commit intorobiot:masterfrom
a8kj7sea:master
Open

Fix memory corruption, thread safety, and click randomization#131
a8kj7sea wants to merge 1 commit intorobiot:masterfrom
a8kj7sea:master

Conversation

@a8kj7sea
Copy link

@a8kj7sea a8kj7sea commented Mar 7, 2026

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 isClicking flag 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.

else
{
int micro_variance = (rand() % 10000) - 5000;
int final_sleep = sleep + micro_variance;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Owner

@robiot robiot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool just two things

if (click(display, args->button, using_xevent, hold_type_ms) == FALSE)
xapp_error("Sending click", -1);

int double_click_delay = 150000 + (rand() % 20000);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same randomization here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants