05-03-26

Notepad Message Spammer Lua Script

This Lua script for Rebind allows you to repeatedly type a custom message into Notepad when you press a key. Customize the message, number of repeats, and delay between each repetition using the UI.

rebindlua scriptnotepadtext spammerkeyboardautomationscript

Question

I want a script that, when I press the 'G' key, types a message in Notepad repeatedly.

Rebind AI

lua
-- rebind: name=Café Message Spammer

local cfg = UI.Schema({
    trigger = UI.Keybind("G", { label = "Trigger Key" }),
    message = UI.Text("I love to eat at big old café", { label = "Message", maxLength = 200 }),
    repeats = UI.Slider(10, { min = 1, max = 100, label = "Number of Times" }),
    delay = UI.Slider(100, { min = 20, max = 500, suffix = "ms", label = "Delay Between Repeats" }),
})

Bind(cfg.trigger, Async(function()
    -- Find and activate Notepad
    local notepad = Window.Find("Notepad")
    if notepad then
        Window.Activate(notepad)
    else
        UI.Notify("Notepad not found. Please open Notepad first.", "warning")
        return
    end

    Sleep(200) -- Give Notepad time to come to focus

    -- Type the message repeatedly
    for i = 1, cfg.repeats do
        HID.Type(cfg.message, 30)
        
        -- Add a newline between repeats (except after the last one)
        if i < cfg.repeats then
            HID.Press("Enter")
            Sleep(cfg.delay)
        end
    end

    UI.Notify("Done! Typed " .. cfg.repeats .. " times", "success")
end))

This script will:

  1. Trigger: When you press the 'G' key.
  2. Action:
    • Find and activate the Notepad window.
    • Type the specified message repeatedly.
    • Add a newline after each message (except the last).
    • Display a success notification when done.

To use:

  1. Open Notepad.
  2. Press the 'G' key (or the key you configure).

Customization:

  • Modify the message variable to change the text.
  • Adjust repeats to control the number of times the message is typed.
  • Change delay to set the pause between each repetition.
  • Change the trigger to any key.