-1

即使在我释放鼠标左键后,脚本有时也会自行单击如何停止。

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
            if IsMouseButtonPressed(1) then
                repeat
                    Sleep(math.random(50, 75))
                    PressMouseButton(1)
                    Sleep(math.random(50, 75))
                    ReleaseMouseButton(1)
                until not IsMouseButtonPressed(1)
            end             
end
4

1 回答 1

1

不可能同时模拟 LMB 按下/释放并确定它是按下还是释放。

但是有一个解决方法:您可以为与 LMB 相同的操作添加替代按钮。
例如,如果 LMB 表示“开火”,则添加键“P”作为在游戏中开火的替代方式。

local key_fire = "P"
EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      Sleep(math.random(100, 150))
      while IsMouseButtonPressed(1) do
         Sleep(math.random(50, 75))
         PressKey(key_fire)
         Sleep(math.random(50, 75))
         ReleaseKey(key_fire)
      end
   end
end

P您通过按 LMB 进行第一次拍摄,脚本将通过在循环中以编程方式按下来进行第二次、第三次……拍摄。

于 2020-06-03T03:27:46.630 回答