interface SystemAPI {
    Sleep(ms: number): void;
    GetClipboard(): string;
    SetClipboard(text: string): void;
    Base64Encode(text: string): string;
    Base64Decode(base64: string): string;
}

Methods

  • Blocks the script thread for the specified duration.

    Parameters

    • ms: number

      Duration to sleep in milliseconds.

    Returns void

    Hotkey, hotstring, and window-activation callbacks continue to fire during sleep — the event loop remains active on the blocking thread.

    System.Sleep(500); // pause for half a second
    
  • Reads the current text content of the system clipboard. Returns an empty string if no text is available.

    Returns string

    Returns "" (empty string) — never null — when the clipboard holds no text or holds non-text content such as an image.

    const text = System.GetClipboard();
    if (text) Console.Log("Clipboard: " + text);
  • Writes text to the system clipboard, replacing its current content.

    Parameters

    • text: string

      The text to place on the clipboard.

    Returns void

    System.SetClipboard("Hello, world!");
    
  • Encodes a UTF-8 string to its Base64 representation.

    Parameters

    • text: string

      The plain text to encode.

    Returns string

    The Base64-encoded string.

    const b64 = System.Base64Encode("hello"); // "aGVsbG8="
    
  • Decodes a Base64 string back to UTF-8 text.

    Parameters

    • base64: string

      The Base64-encoded string.

    Returns string

    The decoded plain text.

    Throws a runtime error if the input is not valid Base64 or does not decode to valid UTF-8.

    const plain = System.Base64Decode("aGVsbG8="); // "hello"