marketplace/productivity

Send to Your AI

v0.1.0

@rebindfree

Select text anywhere and press one key to paste it into ChatGPT, Claude or Codex with your prompt in front.

Gallery

Send to Your AI preview

Readme

Select text in any app and press F8. Rebind copies it, switches to the AI app you pick, and pastes it with your own prompt in front. It stops there, so you can read it before you send.

Needs Rebind 3.5.0 or newer on Windows or macOS. It requests the exec permission so it can open the app on Windows.

Settings

  • Send selection: default F8. Key changes apply while the package runs on Rebind 3.9 or newer; on older versions, restart the package.
  • Send to: Codex, Claude, or ChatGPT desktop app.
  • Starts with: the text placed before your selection.
  • Launch command if the app is closed (Windows): the full path to the app. Without it, Rebind asks Windows to start the app by name, which does not work for every app.

Limits

  • On macOS the app opens if it is closed. On Windows the app should already be open unless you set a launch command.
  • The clipboard is cleared before copying, so whatever it held before is gone, and the pasted text stays on it afterwards.
  • The app gets up to 3 seconds to come to the front before the paste.
  • Notices appear in Rebind. To see them on the desktop, turn on Desktop notifications in Rebind's settings.
  • Live use remains unverified on Windows and macOS.

Stop

Stop the package from the editor toolbar, or press Left Ctrl + Left Alt + K to stop all scripts.

Reviews

No reviews yet. Be the first, from the app.

Source

Version 0.1.0 (current)

main.luau

-- Send to Your AI: copy the selection, switch to your AI app, and paste it
-- with your prompt in front. It stops there, so you send it yourself.

local IS_MAC = _REBIND.platform == "macos"
local MOD = if IS_MAC then "LWin" else "LCtrl"

local cfg = UI.Schema({
  hotkey = UI.Keybind("F8", { label = "Send selection" }),
  app = UI.Select("Codex", { "Codex", "Claude", "ChatGPT" }, { label = "Send to" }),
  prefix = UI.Text("Here is what I am looking at:", { label = "Starts with" }),
  launch = UI.Text("", {
    label = "Launch command if the app is closed (Windows)",
    placeholder = "full path to the app",
  }),
})

local function copySelection()
  Clipboard.Set("")
  HID.Combo(MOD .. "+C")
  for _ = 1, 10 do
    Sleep(50)
    local text = Clipboard.Get()
    if text and text ~= "" then
      return text
    end
  end
  return nil
end

local function waitFront(app)
  for _ = 1, 30 do
    if App.IsFront(app) then
      return true
    end
    Sleep(100)
    pcall(App.Activate, app)
  end
  return false
end

local function focus(app)
  if pcall(App.Activate, app) and waitFront(app) then
    return true
  end
  if IS_MAC then
    return false
  end
  -- Windows focuses only running apps: start it, then keep asking
  local ok = if cfg.launch ~= ""
    then pcall(System.ExecDetached, cfg.launch, {})
    else pcall(System.ExecDetached, "cmd", { "/c", "start", "", app })
  if not ok then
    return false
  end
  return waitFront(app)
end

Bind(
  cfg.hotkey,
  Async(function()
    local text = copySelection()
    if not text then
      UI.Notify("Nothing selected", "warning")
      return
    end
    Clipboard.Set(cfg.prefix .. "\n\n" .. text)
    if not focus(cfg.app) then
      UI.Notify(`Could not open {cfg.app}. Your text is on the clipboard.`, "warning")
      return
    end
    Sleep(400)
    HID.Combo(MOD .. "+V")
  end)
)