clip_manager — clipboard
10/22/22Less than 1 minute
Read, write, and listen for clipboard changes. On Android 10 and later, background apps cannot read or observe the clipboard (OS privacy).
See also
Limited access to clipboard data
Table of contents
Interfaces
Constants
Functions
Constants
clipboardManager
clipboardManager:ClipboardManager
Singleton used to get/set clipboard text and subscribe to clip_changed (when allowed).
See also
Example
const { clipboardManager, getClip } = require('clip_manager');
clipboardManager.on("clip_changed", () => {
console.log("clipboard changed:", getClip());
});
$autojs.keepRunning();Functions
clearClip
clearClip(): void
Clears the clipboard.
Example
"nodejs";
const { clearClip } = require('clip_manager');
clearClip();Returns
void
getClip
getClip(): string | null
Returns the current primary clip as plain text, or null if empty / unavailable.
Example
"nodejs";
const { getClip } = require('clip_manager');
console.log(getClip());Returns
string | null
Plain-text clip contents.
hasClip
hasClip(): boolean
Whether the clipboard currently holds text (or a readable clip).
Example
"nodejs";
const { hasClip } = require('clip_manager');
console.log(hasClip());Returns
boolean
true if there is content, otherwise false.
setClip
setClip(text: string): void
Writes plain text to the clipboard.
Example
"nodejs";
const { setClip } = require('clip_manager');
setClip('Hello World!');Parameters
| Name | Type | Description |
|---|---|---|
text | string | Text to place on the clipboard. |
Returns
void
