05-03-26
Rapid Fire Toggle with Adjustable Speed
This Lua script creates a rapid-fire toggle bound to Mouse4. It allows you to adjust the clicks per second using a UI slider, providing customizable hardware input automation.
rebindlua scriptrapid firetogglehardware inputuislider
Question
I need a Lua script for Rebind that toggles rapid fire on Mouse4, with adjustable speed via a UI slider.
Rebind AI
Here's a Lua script for Rebind that implements a rapid-fire toggle with adjustable speed:
lua
-- rebind: name=Rapid Fire Toggle
-- rebind: process=*
local cfg = UI.Schema({
enabled = UI.Toggle(true, { label = "Enabled" }),
cps = UI.Slider(10, { min = 1, max = 20, label = "Clicks/sec" }),
})
local active = false
local task = nil
Bind("Mouse4", function()
active = not active
if active then
task = Run(function()
while active do
if Input.IsDown("Mouse1") then
HID.Click("Mouse1")
end
Sleep(1000 / cfg.cps)
end
end)
else
if task then task:Cancel() end
end
end)
function OnBlur()
active = false
if task then task:Cancel() end
end
function OnStop()
active = false
if task then task:Cancel() end
endThis script toggles rapid fire when Mouse4 is pressed. While active and Mouse1 is held, it clicks at the rate specified by the slider. The UI panel appears automatically.