罗技 LUA 脚本:MoveMouseRelative 未按预期工作

Logitech LUA Script: MoveMouseRelative not working as expected

我正在尝试编写一个脚本,让我的角色在游戏中旋转 180 度,同时按住 lctrl 并右键单击。此脚本有效,但由于睡眠定时器的原因需要永远旋转:

EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
    if (event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsModifierPressed("lctrl")) then
        for i = 0, 96 do
            MoveMouseRelative (125,0)
            Sleep (1)
        end
    end
end

如果我将 MouseMoveRelative 增加到 125 以上,它就会开始向错误的方向移动鼠标。无论我使用什么值(我尝试过很多介于 100 和 12,000 之间的值),它总是将鼠标向左或向右移动一个非常小的距离。

如果我去掉睡眠函数,结果是不一致的。它通常会在 80-140 度之间旋转我的角色。我怀疑这是因为 MoveMouseRelative 从获取当前鼠标位置开始,它需要延迟才能获得准确的位置。

关于为什么 MouseMoveRelative 不能在 125 以上的值正常工作的任何指导?或者关于如何在 x 轴上瞬间快速移动鼠标 12,000 个相对单位的任何建议?

Or any advice on how to quickly move the mouse 12,000 relative units on the x-axis instantaneously?

如果要瞬间移动相对12000,为什么要移动125的97步,延迟1ms?

97*125 为 12125

为什么不MoveMouseRelative(12125, 0)

根据手册,MoveMouseRelative 需要“几毫秒”才能完成。 1毫秒不是几个。过早读取鼠标位置会给您起始位置。所以我认为垃圾邮件涉及该位置的相对运动可能会导致问题。

If I increase MouseMoveRelative beyond 125, it starts to move the mouse in the wrong direction.

允许的范围是-127...+127

I suspect this is because MoveMouseRelative starts by getting the current mouse position

没有
它不询问当前鼠标位置。
它在没有标志 MOUSEEVENTF_ABSOLUTE 的情况下调用 SendInput() 来模拟相对鼠标移动。

how to quickly move the mouse 12,000 relative units on the x-axis instantaneously?

for i = 0, 96 do
    MoveMouseRelative (125,0)
end

If I eliminate the Sleep function, the results are inconsistent. It usually rotates my character between 80-140 degrees.

尝试 Sleep()

for i = 0, 96 do
    MoveMouseRelative (125,0)
    FastSleep(1)
end