Wrote this in Lua for my Logitech mouse. It's an autoclicker script that should autoclick with intervals between clicks following a normal distribution while holding the back button.
local currentTime = GetRunningTime()
math.randomseed(currentTime)
function gaussianRandom(mean, stddev)
local u1 = math.random()
local u2 = math.random()
local z0 = math.sqrt(-2.0 * math.log(u1)) * math.cos(2.0 * math.pi * u2)
return mean + z0 * stddev
end
function OnEvent(event, arg)
while IsMouseButtonPressed(4) do
PressAndReleaseMouseButton(1)
Sleep(gaussianRandom(800, 200))
end
end
However it only clicks once. If I instead use this code:
min = 500
max = 1000
local currentTime = GetRunningTime()
math.randomseed(currentTime)
function OnEvent(event, arg)
while IsMouseButtonPressed(4) do
PressAndReleaseMouseButton(1)
Sleep(math.random(min,max))
end
end
It autoclicks continuously while holding down the back button. I'm just confused as to why the normal distribution code doesn't work the same way.
Sleep
expects integer amount of milliseconds.
Try
Sleep(math.floor(gaussianRandom(800, 200)))