我为LUA罗技游戏鼠标制作了一个小的反后坐脚本,看起来它确实起到了这个功能,但是当我单次拍摄它完成整个事情时并没有在没有按下鼠标按钮时停止:
function OnEvent(event, arg)
OutputLogMessage("event = %s, arg = %d\n", event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
elseif event == "PROFILE_DEACTIVATED" then
ReleaseMouseButton(2)
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
kaki = not kaki
kus = not kus
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and kaki) then
if kaki then
repeat
Sleep(50)
MoveMouseRelative(0, 1)
Sleep(100)
MoveMouseRelative(0, 16)
Sleep(100)
MoveMouseRelative(0, 26)
Sleep(100)
MoveMouseRelative(-2, 25)
Sleep(100)
MoveMouseRelative(10, 28)
Sleep(100)
MoveMouseRelative(8, 25)
Sleep(100)
MoveMouseRelative(10, 15)
Sleep(100)
MoveMouseRelative(-14, 15)
Sleep(100)
MoveMouseRelative(-34, -1)
Sleep(100)
MoveMouseRelative(-18, 0)
Sleep(100)
MoveMouseRelative(10, 10)
Sleep(100)
MoveMouseRelative(-13, 5)
Sleep(100)
MoveMouseRelative(-20, -5)
Sleep(100)
MoveMouseRelative(-5, 0)
Sleep(100)
MoveMouseRelative(33, 3)
Sleep(100)
MoveMouseRelative(15, 6)
Sleep(100)
MoveMouseRelative(15, 5)
Sleep(100)
MoveMouseRelative(20, 0)
Sleep(100)
MoveMouseRelative(28, -10)
Sleep(100)
MoveMouseRelative(-15, 4)
Sleep(100)
MoveMouseRelative(5, 0)
Sleep(100)
MoveMouseRelative(-8, 8)
Sleep(100)
MoveMouseRelative(-6, 4)
Sleep(100)
MoveMouseRelative(3, -2)
MoveMouseRelative(13, 0)
Sleep(100)
MoveMouseRelative(5, 0)
Sleep(100)
MoveMouseRelative(-15, 0)
Sleep(100)
MoveMouseRelative(-30, 0)
Sleep(100)
MoveMouseRelative(-35, -13)
Sleep(100)
MoveMouseRelative(-13, -4)
Sleep(100)
until not IsMouseButtonPressed(1)
end
end
end
有关如何在中途取消功能或未按下鼠标按钮且循环无法完成并终止最后一次射击的位置的任何建议。
(在我拍摄单拍时的游戏中 - 鼠标移动整个反冲程序)
答案 0 :(得分:0)
尝试使用协程。
if kaki then
local cor = coroutine.create(function()
MoveMouseRelative(0, 1)
coroutine.yield()
MoveMouseRelative(0, 16)
coroutine.yield()
MoveMouseRelative(0, 26)
coroutine.yield()
MoveMouseRelative(-2, 25)
coroutine.yield()
MoveMouseRelative(10, 28)
coroutine.yield()
MoveMouseRelative(8, 25)
coroutine.yield()
MoveMouseRelative(10, 15)
coroutine.yield()
MoveMouseRelative(-14, 15)
coroutine.yield()
MoveMouseRelative(-34, -1)
coroutine.yield()
MoveMouseRelative(-18, 0)
coroutine.yield()
MoveMouseRelative(10, 10)
coroutine.yield()
MoveMouseRelative(-13, 5)
coroutine.yield()
MoveMouseRelative(-20, -5)
coroutine.yield()
MoveMouseRelative(-5, 0)
coroutine.yield()
MoveMouseRelative(33, 3)
coroutine.yield()
MoveMouseRelative(15, 6)
coroutine.yield()
MoveMouseRelative(15, 5)
coroutine.yield()
MoveMouseRelative(20, 0)
coroutine.yield()
MoveMouseRelative(28, -10)
coroutine.yield()
MoveMouseRelative(-15, 4)
coroutine.yield()
MoveMouseRelative(5, 0)
coroutine.yield()
MoveMouseRelative(-8, 8)
coroutine.yield()
MoveMouseRelative(-6, 4)
coroutine.yield()
MoveMouseRelative(3, -2)
MoveMouseRelative(13, 0)
coroutine.yield()
MoveMouseRelative(5, 0)
coroutine.yield()
MoveMouseRelative(-15, 0)
coroutine.yield()
MoveMouseRelative(-30, 0)
coroutine.yield()
MoveMouseRelative(-35, -13)
coroutine.yield()
MoveMouseRelative(-13, -4)
end)
coroutine.resume(cor)
repeat
Sleep(100)
coroutine.resume(cor)
until not IsMouseButtonPressed(1)
end