CopyToClipboard

Copy a string to the Windows clipboard as CF_TEXT (ANSI).

Syntax

Susano.CopyToClipboard(string) -> boolean, string

Parameters

text (string): Bytes to copy. NUL-terminated internally.

Return(s)

ok (boolean): true on success.

On error: nil, err (string).

Behavior

Uses OpenClipboardEmptyClipboardSetClipboardData(CF_TEXT).

On success the OS owns the memory handle.

ANSI only. Non-ASCII may be mangled. Use a Unicode variant if you need UTF-8/UTF-16.

Fails if the clipboard is busy.

Example(s)

local ok, err = Susano.CopyToClipboard("Test 123")
if not ok then print("clipboard error:", err) end

Last updated