我试图让下面的代码在按下或按住鼠标按钮 1 时只执行一次 MoveMouseRelative 函数。我试过删除“重复”行,但它破坏了代码。当前,当激活并按住鼠标 1 时,光标会不断向下拖动。
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) -- to prevent it from being stuck on
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
recoilx2 = not recoilx2
spot = not spot
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilx2) then
if recoilx2 then
repeat
--Sleep(35)
Sleep(5)
MoveMouseRelative(0, 3)
until not IsMouseButtonPressed(1)
end
end