Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SDK Reference

Complete reference for every namespace, function, and hook available in Rebind scripts.

Globals

Run

local handle = Run(fn: function) -> TaskHandle

Launches a function as a coroutine. Returns immediately. The function executes concurrently with other script code.

Returns a TaskHandle with:

  • handle:Cancel() – stop the coroutine
  • handle:IsRunning() – returns boolean

Sleep

Sleep(ms: number)

Pauses the current coroutine for ms milliseconds. Only valid inside a Run() block. Calling Sleep() outside a coroutine will raise a clear error. Does not block anything else.

After

local handle = After(ms: number, fn: function) -> TaskHandle

Shorthand for running a function after a delay. Equivalent to Run(function() Sleep(ms) fn() end). Returns a TaskHandle.

After(2000, function()
    Log.Info("2 seconds later")
end)

Async

local wrappedFn = Async(fn: function) -> function

Returns a new function that automatically runs fn in a coroutine when called. This lets you use Sleep() and other coroutine features inside callbacks that are normally synchronous (like Bind handlers).

When the wrapped function is called from the main thread, it spawns a Run() and returns false (swallow). When called from inside an existing coroutine, it calls fn directly to avoid double-wrapping.

-- without Async: manual Run() wrapping
Bind("F10", function()
    Run(function()
        HID.Down("W")
        Sleep(500)
        HID.Up("W")
    end)
    return false
end)

-- with Async: Sleep() just works
Bind(
    "F10",
    Async(function()
        HID.Down("W")
        Sleep(500)
        HID.Up("W")
    end)
)

Hooks

Global functions your script defines. The runtime calls them when events occur.

Lifecycle

function OnStart()          -- script loaded
function OnStop()           -- script about to unload
function OnFocus(window)    -- target window gained focus ({ title, process, x, y, width, height })
function OnBlur(window)     -- target window lost focus ({ title, process, x, y, width, height })
function OnTick(delta)      -- per-frame update (delta = ms since last tick)

Top-level code runs immediately when the script file is loaded, before OnStart is called. Use it for constants, module initialization, and guards that must run before anything else.

-- top-level: runs at load time
local BASE_SENS = 0.8

function OnStart()
    -- runs after the script is fully registered
    Log.Info("ready, sensitivity = " .. BASE_SENS)
end

OnStart is the right place for anything that needs the script to be fully registered first — such as reading persisted UI values or starting timers.

Input

All input hooks can return false to block the event from reaching the PC, or return true to pass it through.

function OnDown(key)                -- key/button pressed
function OnUp(key, durationMs)      -- key/button released
function OnMove(dx, dy)             -- mouse moved
function OnScroll(delta)            -- vertical scroll

Other (reserved, not yet dispatched)

These hooks are recognized by the script validator but are not dispatched by the relay in the current release. Defining them will not cause errors; they simply won’t fire.

function OnScrollH(delta)           -- horizontal scroll (tilt wheel)
function OnReload()                 -- script reloaded from disk
function OnError(message)           -- runtime error in a hook or coroutine


System

Read-only methods updated automatically every tick.

FunctionReturnsDescription
System.Time()numberCurrent timestamp in milliseconds
System.Mouse()x, yCursor position in pixels (multiple return values)
System.Screen()width, heightPrimary display dimensions in pixels (multiple return values)
System.Window()tableActive window info: { title, process, x, y, width, height }
System.Exec(cmd, options?)tableRun a shell command synchronously

System.Exec

local result = System.Exec(cmd: string, options?: { timeout?: number, cwd?: string })

Runs a shell command (cmd.exe /C on Windows, sh -c on Linux) and returns when it completes.

Returns: { exit: number, stdout: string, stderr: string }

Options:

  • timeout – max execution time in ms (default: 5000). The process is killed if it exceeds this.
  • cwd – working directory for the command.

Output is capped at 64KB per stream. The console window is suppressed on Windows.

-- list files
local result = System.Exec("dir /b", { cwd = "C:\\Users" })
Log.Info(result.stdout)

-- run a Python script
local result = System.Exec("python analyze.py", { timeout = 10000 })
if result.exit ~= 0 then
    Log.Error("Failed: " .. result.stderr)
end

Warning: System.Exec blocks the script tick while the command runs. Place long-running commands inside Run() to avoid stalling input processing.


HID

Sends keyboard and mouse output through the active transport.

Keyboard

FunctionDescription
HID.Down(key)Hold a key or button. Non-blocking, safe anywhere.
HID.Up(key)Release a key or button. Non-blocking, safe anywhere.
HID.Press(key, holdMs?)Tap a key (Down + Sleep + Up). Coroutine only. Default hold: 50ms
HID.Type(text, delayMs?)Type a string character by character. Coroutine only. Default delay: 30ms

Important: HID.Press and HID.Type use Sleep() internally and must be called inside a Run() coroutine or an Async() handler. Calling them outside a coroutine (e.g. directly in OnDown) will raise an error. Use HID.Down/HID.Up for non-blocking key control in hooks, or wrap your logic with Async().

-- WRONG: Press in a hook blocks the hot path
function OnDown(key)
    if key == "F1" then
        HID.Press("A") -- ERROR: not in a coroutine
    end
end

-- CORRECT: use Async to wrap the handler
Bind("F1", Async(function()
    HID.Press("LCtrl+V") -- works: Async provides a coroutine context
end))

-- CORRECT: use Run inside a hook
function OnDown(key)
    if key == "F1" then
        Run(function()
            HID.Press("A") -- works: Run provides a coroutine context
        end)
        return false
    end
    return true
end

-- CORRECT: non-blocking alternative (no coroutine needed)
function OnDown(key)
    if key == "F1" then
        HID.Down("A") -- instant, non-blocking
        return false
    end
    return true
end

Combos

Down, Up, and Press all support + for modifier combos:

HID.Press("LCtrl+V") -- Ctrl+V paste (coroutine only)
HID.Press("LCtrl+LShift+T") -- Ctrl+Shift+T (coroutine only)

HID.Down("LCtrl+LShift") -- hold both modifiers (non-blocking, works anywhere)
HID.Up("LCtrl+LShift") -- release both in reverse order (non-blocking)

HID.Press with combos presses keys left-to-right, sleeps for the hold duration (default 50ms), then releases right-to-left. HID.Down presses left-to-right. HID.Up releases right-to-left.

The + key itself is spelled Equal (unshifted) or KpPlus (numpad), so there is no ambiguity.

Mouse

FunctionDescription
HID.Move(dx, dy)Relative mouse movement (pixels)
HID.MoveTo(x, y)Move to absolute position via relative movement
HID.Scroll(amount)Vertical scroll (positive = up)

Mouse Mode

FunctionDescription
HID.SetMouseMode(mode)"relative" or "absolute"
HID.GetMouseMode()Returns current mode string

Relative mode (default): single-pass movement, fast (~0.5ms), may drift. Best for games.

Absolute mode: iterative correction with position validation, slower (1-3ms), sub-5px accuracy. Best for desktop automation.


Input

Reads the current physical state of input devices.

FunctionReturnsDescription
Input.IsDown(key)booleanWhether key/button is currently held
Input.GetDuration(key)numberMilliseconds held, 0 if not pressed
Input.GetActiveKeys()string[]All currently held keys
Input.GetMousePos(){x, y}Current cursor position
Input.GetModifiers()table{ctrl, shift, alt, win} booleans

UI

Defines a settings panel rendered in the Rebind UI.

Schema

local cfg = UI.Schema({
    key = UI.Widget(default, options?),
    ...
})

Returns a proxy handle. Read values with cfg.key, write with cfg.key = value.

Widgets

ConstructorDefault TypeDescription
UI.Toggle(default, opts?)booleanOn/off switch
UI.Slider(default, opts?)numberNumeric slider
UI.Keybind(default, opts?)stringKey binding selector
UI.Select(default, choices, opts?)stringDropdown selection
UI.Text(default, opts?)stringText input field

Widget Options

OptionTypeApplies toDescription
labelstringallDisplay label (overrides key name)
tooltipstringallHover description
groupstringallVisual section header
tabstringallTab panel name
showIfstringallShow only when referenced toggle is on
minnumberSliderMinimum value
maxnumberSliderMaximum value
stepnumberSliderIncrement size
suffixstringSliderUnit label (e.g. "%")
placeholderstringTextHint when empty
maxLengthnumberTextCharacter limit

Other

FunctionDescription
UI.Get(id)Read value by string key
UI.Set(id, value)Write value by string key
UI.GetAll()All current values as a table
UI.Notify(message, variant?)Show notification. Variant: "info" (default), "success", "warning", "error"

Persistence

Values are saved automatically on every change and restored at startup. Persistence is keyed to the script’s file path – no configuration required.


Macro

Record and play back input sequences.

Playback

FunctionDescription
Macro.Play(macro, speed?, mode?)Play a macro. Returns a handle.
Macro.StopAll()Stop all running macros

Speed: 1.0 = normal, 0.5 = half speed, 2.0 = double speed. Default: 1.0.

Mode: "parallel" (default), "replace".

Handle methods:

  • handle:Stop()
  • handle:Pause()
  • handle:Resume()
  • handle:IsPlaying() – returns boolean
  • handle:GetProgress() – returns 0.0 to 1.0
  • handle:Wait() – blocks the current coroutine until playback ends. must be called inside Run()

Hardware Streaming

FunctionDescription
Macro.Stream(macro)Stream to device for hardware-precision playback
Macro.Abort()Stop device-side playback immediately

Macros containing "type" actions always play host-side, since firmware cannot render text. Macro.Play() automatically falls back to host-side execution when any Type action is present.

Recording

FunctionDescription
Macro.Record(options?)Start recording input events
Macro.Finish()Stop recording, return macro table

Record options: { ignoreMouse = false, ignoreKeyboard = false, precision = "normal" }

Format

Actions in a macro table:

ActionFieldsDescription
(shorthand)x, y, delayMouse movement
"move"dx, dy, delayMouse movement (explicit)
"down"code, delayHold key
"up"code, delayRelease key
"press"code, holdMs, delayTap key
"type"text, charDelay, delayType string
"scroll"amount, delayScroll wheel
"sleep"delayPause

Timer

FunctionReturnsDescription
Timer.After(ms, callback)handleExecute once after delay
Timer.Every(ms, callback)handleExecute repeatedly at interval
Timer.CancelAll()Cancel all active timers

Handle methods: handle:Cancel(), handle:Pause(), handle:Resume()


Math

Random

FunctionReturnsDescription
Math.Random(min, max)numberUniform random number
Math.Gaussian(mean, stdDev)numberNormal distribution random

Transforms

All transform functions return a new table (original is unchanged).

FunctionDescription
Math.Scale(macro, xFactor, yFactor)Multiply movement values
Math.Spline(macro, tension)Catmull-Rom curve smoothing
Math.Resample(macro, intervalMs)Normalize timing to fixed intervals
Math.Interpolate(macro, intervalMs)Add smooth intermediate movement steps
Math.TimeComp(macro, targetMs)Scale total duration to target

Interpolate vs Resample:

  • Resample changes all delays uniformly (normalizing recorded macros)
  • Interpolate adds intermediate steps between existing points (smoothing patterns)

JSON

FunctionReturnsDescription
JSON.Parse(str)tableParse JSON string to Luau table
JSON.Stringify(tbl)stringSerialize table to JSON string

Log

FunctionDescription
Log.Info(message)Info-level log
Log.Warn(message)Warning-level log
Log.Error(message)Error-level log
Log.Debug(message)Debug-level log (dev mode only)

Globals: print(...) and log(...) are both aliases for Log.Info. They accept multiple arguments, joined by tabs — identical to standard Lua print behaviour.

log("feature enabled, sensitivity =", sensitivity)
print("device ready")

Logs appear in the Rebind UI Logs tab.


File

All paths are relative to your script’s directory. Path traversal (..) is rejected.

FunctionReturnsDescription
File.Read(path)stringRead file contents
File.Write(path, content)Overwrite file
File.Append(path, content)Append to file
File.Exists(path)booleanCheck if file exists
File.Delete(path)booleanDelete file
File.List(path)string[]List directory contents
File.MkDir(path)booleanCreate directory
File.ReadJSON(path)tableRead and parse JSON file
File.WriteJSON(path, table)Write table as JSON
File.GetScriptDir()stringAbsolute path to script directory

Net

Client

FunctionReturnsDescription
Net.Get(url, headers?, options?)responseHTTP GET
Net.Post(url, body, headers?, options?)responseHTTP POST
Net.Put(url, body, headers?, options?)responseHTTP PUT
Net.Patch(url, body, headers?, options?)responseHTTP PATCH
Net.Delete(url, headers?, options?)responseHTTP DELETE
Net.Head(url, headers?, options?)responseHTTP HEAD
Net.Request(options)responseGeneric HTTP request

Response: { status: number, body: string, headers: table }

Options: { timeout = milliseconds } – optional trailing table for convenience methods.

Net.Request options: { method: string, url: string, body?: string, headers?: table, timeout?: number }

-- simple GET
local resp = Net.Get("https://api.example.com/data")

-- POST with headers
local resp = Net.Post(
    "https://api.example.com/data",
    JSON.Stringify({ key = "value" }),
    { ["Content-Type"] = "application/json", ["Authorization"] = "Bearer token" }
)

-- DELETE with timeout
local resp = Net.Delete("https://api.example.com/item/123", nil, { timeout = 5000 })

-- generic request
local resp = Net.Request({
    method = "PATCH",
    url = "https://api.example.com/item/123",
    body = JSON.Stringify({ name = "updated" }),
    headers = { ["Content-Type"] = "application/json" },
    timeout = 10000,
})

Custom headers (including User-Agent) can be set on any request via the headers table.

HTTP Server

local server = Net.Listen(port, handler)

Handler: receives request, returns { status, body, headers? }.

Server handle: server:Stop()

Example:

local server = Net.Listen(8080, function(req)
    if req.method == "POST" then
        local data = JSON.Parse(req.body)
        return { status = 200, body = "OK" }
    end
    return { status = 404, body = "Not Found" }
end)

WebSocket Server

local server = Net.WSListen(port, handlers)

Handlers table: all optional.

HandlerSignatureFires when
OnConnectfunction(client)a new client has completed the WS handshake
OnMessagefunction(client, payload, is_binary)the server received a frame
OnClosefunction(client)the connection was closed (by either side)

Client handle (passed to handlers): client.id, client:Send(text), client:SendBinary(bytes), client:Close().

Server handle: server:Broadcast(text), server:BroadcastBinary(bytes), server:ClientCount(), server:Stop().

The server binds 0.0.0.0:<port>. Events are dispatched to Lua handlers on the script’s tick loop. Up to 32 events are processed per tick per server; excess messages backlog into the next tick. There is no built-in rate limiting — scripts exposed to untrusted networks should implement their own.

Performance characteristics (localhost, Windows host):

MetricValue
Round-trip RPC (p50)~1 ms
Round-trip RPC (p99)~2 ms
Sustained RPC throughput (16 in-flight)~10,000 req/s
Server-side message drain~12,000 msg/s
Client wire throughput (fire-and-forget)~100,000 msg/s

Each connection uses a dedicated reader thread that blocks on the socket and a writer thread that blocks on the outbound queue — writes dispatch with zero polling latency. TCP_NODELAY is set on all accepted sockets so small request/response traffic does not pay Nagle’s algorithm cost. On Windows the relay raises the system timer resolution to 1 ms so the tick loop actually runs at its declared rate.

Example:

local server = Net.WSListen(19561, {
    OnMessage = function(client, payload, is_binary)
        if payload == "hello" then
            client:Send("world")
        else
            server:Broadcast("someone said: " .. payload)
        end
    end,
})

WebSocket Client

local conn = Net.WSConnect(url, handlers)

URL: ws://host:port/path or wss://host:port/path. TLS via rustls (webpki roots).

Handlers table: all optional.

HandlerSignatureFires when
OnOpenfunction()the WS handshake completed
OnMessagefunction(payload, is_binary)a frame arrived from the server
OnClosefunction()the connection closed

Connection handle: conn:Send(text), conn:SendBinary(bytes), conn:Close().

Example:

local conn = Net.WSConnect("wss://echo.websocket.events", {
    OnOpen = function()
        conn:Send("hello from rebind")
    end,
    OnMessage = function(payload, is_binary)
        Log.Info("got: " .. payload)
    end,
})

Screen

FunctionReturnsDescription
Screen.GetPixelColor(x?, y?)stringHex color "RRGGBB" at pixel coordinates. If no args, reads at current mouse position.

Note: ~500us latency per call. Use sparingly.


Window

Window manipulation functions. Handles are integer values obtained from Window.Find() or Window.List(). Passing nil for a handle targets the active (foreground) window.

Query

FunctionReturnsDescription
Window.Find(title)number?Find first visible window whose title contains title (case-insensitive). Returns handle or nil.
Window.List(title?){WindowEntry}List all visible windows. Optional title filter. Each entry has handle, title, process, x, y, width, height.
Window.GetTitle(handle?)stringGet window title.
Window.GetPos(handle?){x, y, width, height}Get window position and size.
Window.GetPID(handle?)numberGet the process ID that owns the window.
Window.IsVisible(handle)booleanCheck if a window is visible.

Activation

FunctionDescription
Window.Activate(handle)Bring window to foreground. Auto-restores if minimized.

Movement / Sizing

FunctionDescription
Window.Move(handle, x?, y?, w?, h?)Move and/or resize. Omit any param to leave unchanged.

State Control

FunctionDescription
Window.Minimize(handle?)Minimize to taskbar.
Window.Maximize(handle?)Maximize to full screen.
Window.Restore(handle?)Restore from minimized or maximized.
Window.Close(handle?)Graceful close (sends WM_CLOSE).

Appearance

FunctionDescription
Window.SetAlwaysOnTop(handle, on?)Pin window above all others. on defaults to true.
Window.SetTransparency(handle, level)Set opacity: 0 (invisible) to 255 (opaque).
Window.SetTitle(handle, title)Change the window’s title bar text.

Waiting

FunctionReturnsDescription
Window.Wait(title, timeout?)number?Wait for a window to appear. Must be called inside Run(). Timeout in ms (default 5000). Returns handle or nil.

Examples

-- find and reposition a window
local hw = Window.Find("Notepad")
if hw then
    Window.Move(hw, 0, 0, 800, 600)
    Window.Activate(hw)
end

-- pin active window on top
local hw = Window.Find(System.Window().title)
if hw then
    Window.SetAlwaysOnTop(hw, true)
end

-- list all windows
for _, w in ipairs(Window.List()) do
    Log.Info(w.title .. " [" .. w.process .. "]")
end

-- wait for a game to launch
Run(function()
    local hw = Window.Wait("Counter-Strike 2", 30000)
    if hw then
        Window.Maximize(hw)
    end
end)

Audio

FunctionReturnsDescription
Audio.Beep()Play system beep
Audio.Play(path, options?)SoundHandlePlay an audio file (WAV, MP3, OGG, FLAC). Non-blocking.
Audio.StopAll()Stop all playing sounds
Audio.SetMasterVolume(vol)Set master volume (0.0 to 1.0)
Audio.GetMasterVolume()numberGet current master volume

Audio.Play

local sound = Audio.Play("alert.wav")
local music = Audio.Play("bgm.mp3", { volume = 0.5, loop = true })

Options:

OptionTypeDefaultDescription
volumenumber1.0Playback volume (0.0 to 1.0)
loopbooleanfalseRepeat when playback finishes

File paths are relative to the script directory (same sandboxing rules as File).

SoundHandle

The object returned by Audio.Play:

MethodReturnsDescription
sound:Stop()Stop playback and release resources
sound:Pause()Pause playback
sound:Resume()Resume paused playback
sound:IsPlaying()booleanTrue if playing (not paused, not finished)
sound:SetVolume(vol)Set per-sound volume (0.0 to 1.0)
sound:GetVolume()numberGet current per-sound volume

Always call Audio.StopAll() in OnStop and OnBlur to clean up playing sounds.


Clipboard

Read and write the system clipboard.

FunctionReturnsDescription
Clipboard.Get()string?Read current clipboard text. Returns nil if empty or non-text.
Clipboard.Set(text)Set clipboard text.
-- paste a multi-line message into Discord
local msg = "Line one\nLine two\nLine three"
Clipboard.Set(msg)
HID.Press("LCtrl+V")

-- read clipboard contents
local text = Clipboard.Get()
if text then
    Log.Info("Clipboard: " .. text)
end

Clipboard paste is the most reliable way to input multi-line or long text. Applications handle pasted newlines correctly, and there are no per-character timing concerns.


Dialog

Native OS dialogs for messages, confirmations, and file selection. All functions must be called inside Run() — they yield the coroutine while the dialog is open. Input processing, timers, and other coroutines continue running uninterrupted.

Linux/BSD: requires Zenity, KDialog, or YAD to be installed.

Message and Confirm

FunctionReturnsDescription
Dialog.Message(text, options?)Show an alert box. Yields until dismissed.
Dialog.Confirm(text, options?)booleanShow a yes/no dialog. Returns true if the user clicked Yes.

Options: { title?: string, level?: string }

level controls the icon: "info" (default), "warning", "error".

Run(function()
    Dialog.Message("Script finished.", { title = "Done" })

    local ok = Dialog.Confirm("Overwrite existing file?", { title = "Confirm", level = "warning" })
    if not ok then
        return
    end
end)

File Dialogs

FunctionReturnsDescription
Dialog.OpenFile(options?)string?Pick a single file. Returns path or nil if cancelled.
Dialog.OpenDir(options?)string?Pick a directory. Returns path or nil if cancelled.
Dialog.SaveFile(options?)string?Choose a save location. Returns path or nil if cancelled.

Options: { title?: string, location?: string, filters?: { { name: string, extensions: { string } } } }

  • location – initial directory the dialog opens in.
  • filters – restrict the file types shown. Each entry has a display name and a list of extensions (without leading dot).
Run(function()
    -- open a single Lua file
    local path = Dialog.OpenFile({
        title = "Open Script",
        filters = {
            { name = "Lua Scripts", extensions = { "lua", "luau" } },
        },
    })
    if path then
        local code = File.Read(path)
    end

    -- save a file
    local dest = Dialog.SaveFile({
        title = "Save As",
        location = File.GetScriptDir(),
        filters = {
            { name = "JSON", extensions = { "json" } },
        },
    })
    if dest then
        File.WriteJSON(dest, data)
    end

    -- pick a directory
    local dir = Dialog.OpenDir({ title = "Select Output Folder" })
    if dir then
        Log.Info("Output: " .. dir)
    end
end)

Regex

Pattern matching using regular expressions (PCRE-style syntax via the Rust regex crate). Backtracking-free by design – no risk of catastrophic backtracking.

Use [[ ]] long strings for patterns to avoid Luau escape interpretation: [[\d+]] instead of "\\d+".

FunctionReturnsDescription
Regex.IsMatch(text, pattern)booleanTest if text matches the pattern
Regex.Find(text, pattern)table?First match with captures, or nil
Regex.FindAll(text, pattern){table}All matches with captures
Regex.Replace(text, pattern, rep)stringReplace first match
Regex.ReplaceAll(text, pattern, rep)stringReplace all matches
Regex.Split(text, pattern){string}Split text on pattern

Match result

Regex.Find and Regex.FindAll return tables with:

{
    match = "full matched text",
    captures = { "group1", "group2" },  -- positional capture groups
    start = 8,    -- 1-indexed byte offset of match start
    finish = 11,  -- 1-indexed byte offset of match end
}

Replacement syntax

Replacements use $1, $2, etc. for capture group references:

Regex.ReplaceAll("John Smith", [[(\w+) (\w+)]], "$2, $1") --> "Smith, John"

Examples

-- test a pattern
if Regex.IsMatch(win.process, "discord|slack|teams") then
    -- chat app behavior
end

-- extract data
local m = Regex.Find("Price: 500g", [[(\d+)g]])
if m then
    local amount = tonumber(m.captures[1]) --> 500
end

-- split CSV
local fields = Regex.Split("a,b,,d", ",") --> {"a", "b", "", "d"}

Note: Luau also has built-in Lua patterns (string.find, string.match, string.gmatch) which use different syntax (%d instead of \d). The Regex namespace uses standard regex syntax and supports features Lua patterns lack: alternation (|), non-greedy quantifiers, lookahead, and more.


Config

Read and write TOML configuration files. TOML is a superset of INI for common use cases – simple key = value files work as-is, with support for typed values (booleans, numbers, strings), arrays, and nested tables.

FunctionReturnsDescription
Config.ParseTOML(text)tableParse a TOML string into a Lua table
Config.ToTOML(table)stringSerialize a Lua table to a TOML string
Config.ReadTOML(path)tableRead and parse a TOML file
Config.WriteTOML(path, table)Serialize and write a TOML file

File paths are relative to the script directory (same sandboxing rules as File).

-- settings.toml:
-- [general]
-- sensitivity = 0.8
-- enabled = true
-- weapon = "ak47"

local cfg = Config.ReadTOML("settings.toml")
Log.Info(cfg.general.sensitivity) --> 0.8
Log.Info(cfg.general.weapon) --> "ak47"

-- modify and save
cfg.general.sensitivity = 1.0
Config.WriteTOML("settings.toml", cfg)

For JSON config files, use the File.ReadJSON / File.WriteJSON functions in the File namespace.


Pipe

Shared memory IPC for communicating with external processes (Python, Node.js, etc).

Opening

local pipe = Pipe.Open(name, options?)

Creates or opens a shared memory region. Options: { size = 65536 } (min 1024, max 16MB).

Methods

MethodReturnsDescription
pipe:Read()string or nilRead latest data from external process. nil if nothing new.
pipe:Write(data)Write data for external process to read
pipe:Close()Release shared memory

Properties

PropertyTypeDescription
pipe.namestringPipe name
pipe.sizenumberTotal shared memory size
pipe.capacitynumberMax payload size per message

Script

FunctionDescription
Script.Exit(reason?)Stop the current script. Optional reason is logged.
Script.Reload()Reload the current script from disk

Globals: exit(reason?) and die(reason?) are aliases for Script.Exit.

die("shutting down for maintenance")

Bind

Declarative key binding as an alternative to writing OnDown/OnUp handlers.

-- simple binding (action on press, key is blocked by default)
local handle = Bind("F10", function()
    HID.Type("Hello!")
end)

-- explicitly pass the key through to the PC
local handle = Bind("F10", function()
    Log.Info("F10 was pressed")
    return true -- pass through (must be explicit)
end)

-- binding with condition, press, and release handlers
local handle = Bind("Mouse1", {
    when = function()
        return Input.IsDown("LAlt") -- only activate when Alt is held
    end,
    action = function()
        Log.Info("pressed")
    end,
    release = function()
        Log.Info("released")
    end,
})

-- toggle a UI boolean on keypress
local handle = Bind.Toggle("F9", "enabled")

-- simple remap (no logic needed)
local handle = Bind.Remap("Mouse4", "4")

Blocking

Bind blocks by default. This is the opposite of OnDown/OnUp.

Return valueOnDown/OnUpBind action
return truepass throughpass through
return falseblockblock
no return / nilpass throughblock

Most binds remap or trigger actions where blocking the original key is what you want. To pass the key through, you must explicitly return true.

When using Async() with Bind, the wrapper always returns false (block) immediately when it spawns the coroutine. Any return value inside the coroutine body has no effect on propagation – the decision was already made.

Handle

Handle methods: handle:unbind(), handle:disable(), handle:enable(), handle.enabled (read-only).

Routing

Keys claimed by Bind do not reach OnDown/OnUp. If a bind’s when guard returns false, the key falls through to the next bind or to OnDown/OnUp.


Modeline

-- rebind: key=value [key=value ...]
PropertyTypeDefaultDescription
namestringfilenameDisplay name
versionstring"0.0.0"Script version
authorstringCreator attribution
descriptionstringBrief explanation
min_sdkstringcurrentMinimum SDK version required
windowstringWindow title match (repeatable, case-insensitive)
processstringProcess name match (repeatable, case-insensitive)
tick_ratenumber1000OnTick frequency in Hz (max 8000)
z_indexinteger1Input priority (higher = first)
instancestring"replace""replace", "single", or "multiple"
mouse_modestring"relative""relative" or "absolute"
mouse_blockbooleanfalseWhen true, OnMove can block mouse input by returning false. When false, moves are forwarded immediately and OnMove fires asynchronously.
permissionstringGrant a permission to this script (repeatable). Valid values: exec, net. See Permissions below.
idstringDeprecated. Silently ignored. UI persistence is now automatic via file path.

Rules:

  • String-valued keys (name, description, author, window, process) must appear alone on their line
  • Scalar keys (tick_rate, z_index, etc.) can share a line
  • List fields use repeated keys: one window= per pattern, one process= per process, one permission= per permission

Permissions

By default, scripts can access all namespaces. If any permission= line is present, only the listed permissions are granted and all others are denied.

-- rebind: permission=exec
-- rebind: permission=net

-- now only exec and net are allowed; other restricted namespaces are open
PermissionRestricts
execSystem.Exec()
netNet.Get(), Net.Post(), Net.Put(), Net.Patch(), Net.Delete(), Net.Head(), Net.Request(), Net.Listen(), Net.WSListen(), Net.WSConnect()

Scripts published to the marketplace should declare the minimum permissions they need. Scripts without any permission= line have full access (backward compatible default).


Key Reference

Key names are case-insensitive. "F1", "f1", and "F1" are all identical. Use these strings with HID.Down, HID.Up, HID.Press, Bind, and in OnDown/OnUp hooks.

Letters

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Numbers

0 1 2 3 4 5 6 7 8 9

Function Keys

F1 through F24. F13-F24 are HID output only (they work with HID.Press but will not appear in OnDown/OnUp hooks).

Mouse Buttons

ButtonName
Left clickMouse1
Right clickMouse2
Middle clickMouse3
BackMouse4
ForwardMouse5

Modifiers

KeyNameAliases
Left CtrlLCtrlCtrl, Control
Right CtrlRCtrl
Left ShiftLShiftShift
Right ShiftRShift
Left AltLAltAlt
Right AltRAlt
Left Win / CmdLWinWin, GUI, Windows, Command, Meta
Right Win / CmdRWinRGui, RMeta

Editing and Control

KeyNameAliases
EnterEnterReturn
EscapeEscapeEsc
BackspaceBackspace
TabTab
SpaceSpace
Caps LockCapsLock
KeyNameAliases
InsertInsert
DeleteDeleteDel
HomeHome
EndEnd
Page UpPageUpPgUp
Page DownPageDownPgDn
Arrow UpUp
Arrow DownDown
Arrow LeftLeft
Arrow RightRight

System

KeyNameAliases
Print ScreenPrintScreenPrintScr, PrtSc
Scroll LockScrollLock
Pause / BreakPauseBreak
Application / MenuMenuApp, ContextMenu

Punctuation

These names refer to the physical key, regardless of shift state.

KeyNameAliases
- / _Minus
= / +EqualEquals
[ / {LeftBracketLeftBrace, LBracket
] / }RightBracketRightBrace, RBracket
\ / |Backslash
; / :Semicolon
' / "ApostropheQuote
` / ~GraveBacktick, Tilde
, / <Comma
. / >PeriodDot
/ / ?Slash

Numpad

KeyNameAliases
Num LockNumLock
Numpad /KpDivideNpDivide
Numpad *KpMultiplyNpMultiply, KpAsterisk
Numpad -KpMinusNpSubtract
Numpad +KpPlusNpAdd
Numpad EnterKpEnterNpEnter
Numpad .KpDotNpDecimal, NpDot
Numpad 0-9Kp0 through Kp9NP0-NP9, Numpad0-Numpad9

Media Keys (HID Output Only)

These can be sent via HID.Press but will not appear in input hooks.

KeyNameAliases
Next TrackMediaNextMediaNextTrack
Previous TrackMediaPrevMediaPrevTrack
StopMediaStop
Play / PauseMediaPlayMediaPlayPause
Volume UpVolumeUpVolUp
Volume DownVolumeDownVolDown
MuteMuteVolumeMute