即使我松开了鼠标左键,脚本有时仍会不断点击自身,如何停止此操作。
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
答案 0 :(得分: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
您可以通过按LMB来拍摄第一张照片,然后脚本将在循环中以编程方式按 P 来拍摄第二张,第三张...。