I am trying to create a script in .lua on GHub for my mouse. I have to make a lot of movements really quickly, inputting 10 MoveMouseRelative every second and a half. But I have found that the positions change a lot where they shouldn't. During my tests I discovered that the script is executed in different timespans, like, a certain line should be run at second 2, and sometimes it's executed on second 2.1 or 1.9. I think it's because of the available processing power in my computer, but I don't know for sure. What can I do to fix that and have sure that the script is executed always on the same timespan and that the positions are always the same?
I made some tests and the scrip always executes in a different way every time I test it I want it to be able to execute the same way every time
function OnEvent(event, arg)
OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
if IsMouseButtonPressed(3) then
repeat
if IsMouseButtonPressed(1) then Sleep(11)
repeat
--2
Sleep(11)
MoveMouseRelative(-1, 8)
Sleep(11)
MoveMouseRelative(-1, 7)
Sleep(11)
MoveMouseRelative(0, 6)
Sleep(11)
MoveMouseRelative(0, 6)
Sleep(11)
MoveMouseRelative(0, 6)
Sleep(11)
MoveMouseRelative(0, 5)
Sleep(11)
MoveMouseRelative(0, 5)
Sleep(11)
MoveMouseRelative(0, 2)
Sleep(11)
MoveMouseRelative(0, 2)
Sleep(11)
MoveMouseRelative(0, 2)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--3
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--4
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--5
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--6
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--7
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--8
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--9
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
Sleep(11)
MoveMouseRelative(-3, 4)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--10
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--11
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-200, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--12
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--13
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--14
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--15
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--16
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--17
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--18
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--19
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--20
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--21
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--22
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--23
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--24
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--25
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--26
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--27
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--28
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--29
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
--30
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
Sleep(11)
MoveMouseRelative(-2, 3)
if not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3)) then break end
Sleep(12)
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(3)
end
end