0% found this document useful (0 votes)
4 views2 pages

using ImGuiNET;

The AutoClicker class allows users to automate mouse clicks in a game, with adjustable clicks per second (CPS) and an option for randomizing click timing. It utilizes ImGui for rendering the user interface and manages the clicker operation through a separate task that runs in the background. The class includes methods to start and stop the clicker, ensuring it only operates when the game is focused and a specific key is pressed.

Uploaded by

wftmano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

using ImGuiNET;

The AutoClicker class allows users to automate mouse clicks in a game, with adjustable clicks per second (CPS) and an option for randomizing click timing. It utilizes ImGui for rendering the user interface and manages the clicker operation through a separate task that runs in the background. The class includes methods to start and stop the clicker, ensuring it only operates when the game is focused and a specific key is pressed.

Uploaded by

wftmano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using ImGuiNET;

using ILoveWomen.Common;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace ILoveWomen.Modules
{
public class AutoClicker
{
private bool _enabled = false;
private float _cps = 10.0f;
private bool _randomization = false;
private CancellationTokenSource? _clickerTokenSource;
private Task? _clickerTask;

public bool IsEnabled => _enabled;

public void Render()


{
bool prevEnabled = _enabled;
ImGui.Checkbox("Enable Autoclicker", ref _enabled);

if (prevEnabled != _enabled)
{
if (_enabled)
StartClicker();
else
StopClicker();
}

ImGui.Spacing();

ImGui.Text("Clicks Per Second:");


ImGui.SliderFloat("##CPS", ref _cps, 1.0f, 20.0f, "%.1f");

ImGui.Spacing();

ImGui.Checkbox("Randomize Timing", ref _randomization);


if (_randomization)
{
ImGui.SameLine();
ImGui.TextDisabled("(?)");
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextUnformatted("Adds slight randomness to click timing
to appear more natural");
ImGui.EndTooltip();
}
}
}

private void StartClicker()


{
_clickerTokenSource = new CancellationTokenSource();
_clickerTask = Task.Run(() => ClickerLoop(_clickerTokenSource.Token),
_clickerTokenSource.Token);
}
private void StopClicker()
{
if (_clickerTokenSource != null)
{
_clickerTokenSource.Cancel();
_clickerTokenSource = null;
}
_clickerTask = null;
}

private async Task ClickerLoop(CancellationToken token)


{
Random random = new Random();

while (!token.IsCancellationRequested)
{
if (_enabled && Utils.IsMinecraftFocused() &&
Utils.IsKeyPressed(Utils.VK_LBUTTON))
{
int baseDelay = (int)(1000 / _cps);
int delay = baseDelay;

if (_randomization)
{
int variation = (int)(baseDelay * 0.2);
delay = random.Next(baseDelay - variation, baseDelay +
variation);
}

Utils.mouse_event(Utils.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Utils.mouse_event(Utils.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);

await Task.Delay(delay, token);


}
else
{
await Task.Delay(10, token);
}
}
}

public void Dispose()


{
StopClicker();
}
}
}

You might also like