Skip to content

Clipboard API ​

Provides read and write operations for plain text, rich text (HTML Format), and file lists (CF_HDROP) on the Windows clipboard.

clipboard ​

clipboard.read ​

Report what the Windows clipboard holds: text, a file list, an image.

This method takes no parameters.

Returns

FieldTypeDescription
hasTextbooleanThe clipboard holds text (CF_UNICODETEXT or CF_TEXT).
hasImagebooleanThe clipboard holds a bitmap (CF_DIB or CF_BITMAP). The image itself is not returned.
hasFilesbooleanThe clipboard holds a file list (CF_HDROP) with at least one file.
textstringThe text; empty when the clipboard holds none.
filesstring[]The file paths, present only when hasFiles is true.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
const result = await fb2k.invoke('clipboard.read');

clipboard.write ​

Replace the clipboard contents with Unicode text.

ParameterTypeRequiredDescription
textstringYesText to place on the clipboard. Must not be empty.

Returns

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('clipboard.write', { text: 'copied text' });

clipboard.writeFiles ​

Place a file list on the clipboard (CF_HDROP) for Explorer and other shell targets to paste.

ParameterTypeRequiredDescription
pathsstring[]YesAbsolute file paths, in the order they are placed on the clipboard. Must not be empty.

Returns

FieldTypeDescription
fileCountintegerNumber of paths placed on the clipboard.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('clipboard.writeFiles', { paths: ['C:\\Music\\song.flac'] });

clipboard.writeHTML ​

Replace the clipboard contents with rich text in HTML Format, plus a plain-text fallback.

ParameterTypeRequiredDescription
htmlstringYesHTML fragment to write as HTML Format. Must not be empty.
plainTextstringNoPlain-text fallback written as CF_UNICODETEXT; when omitted or empty, the HTML text itself.

Returns

FieldTypeDescription
htmlWrittenbooleanThe HTML Format data was placed on the clipboard.
textWrittenbooleanThe plain-text fallback was placed on the clipboard.

success is true on success. On failure the response is { success: false, error, code }; see Error codes for code.

js
await fb2k.invoke('clipboard.writeHTML', { html: '<b>Now playing</b>' });

Owner-family behavior and limits ​

  • clipboard.writeFiles accepts media-read-authorized paths. clipboard.writeHTML writes HTML plus a plain-text fallback; clipboard.read reports only formats currently available from the Windows clipboard.