Click Assist

@rebind / click-assistv0.1.2Public

Drag without holding the button, or turn one press into a timed hold or a double click.

Files

main.luau1.4 KB

-- Click Assist: three ways to press a button for hands that can press but
-- not hold. Toggle Click latches it, Hold Assist turns a tap into a timed
-- hold, Double Click turns one press into two.

local cfg = UI.Schema({
  button = UI.Keybind("Mouse1", { label = "Button to assist" }),
  mode = UI.Select(
    "Toggle Click",
    { "Toggle Click", "Hold Assist", "Double Click" },
    { label = "Mode" }
  ),
  hold_time = UI.Slider(500, {
    min = 100,
    max = 3000,
    suffix = " ms",
    label = "Hold Assist length",
  }),
  double_gap = UI.Slider(50, {
    min = 20,
    max = 200,
    suffix = " ms",
    label = "Double Click gap",
  }),
})

local button = cfg.button
local latched = false

Bind(button, {
  action = function()
    if cfg.mode == "Toggle Click" then
      latched = not latched
      if latched then
        HID.Down(button)
        UI.Notify("Button held", "info")
      else
        HID.Up(button)
        UI.Notify("Button released", "info")
      end
    elseif cfg.mode == "Hold Assist" then
      Run(function()
        HID.Down(button)
        Sleep(cfg.hold_time)
        HID.Up(button)
      end)
    else
      Run(function()
        HID.Press(button, 30)
        Sleep(cfg.double_gap)
        HID.Press(button, 30)
      end)
    end
  end,
  release = function() end,
})

function OnStop()
  if latched then
    HID.Up(button)
  end
end

3 files, 3.1 KB.