hammerspoon2-docs
    Preparing search index...

    Function writeItems

    • Write one or more pasteboard items atomically, replacing all current contents.

      Each element of items is an object mapping UTI type strings to either strings or binary data (Uint8Array, typed array, or ArrayBuffer), matching the shape returned by readItems(). Use this to restore multi-item clipboard contents (such as multiple copied files) or arbitrary multi-UTI binary payloads without losing fidelity.

      An item whose only key is "public.file-url" is written as a file URL, the same way writeURLs() writes it. Items with other representations as well are written as raw data. Either way, sandboxed apps that paste a "public.file-url" can open the file, so a Finder copy saved with readItems() can be restored with writeItems() and pasted as files.

      If any item isn't an object with at least one string or binary value, nothing is written. Within an item, values that aren't strings or binary data are skipped, with a warning in the Console.

      Parameters

      • items: Record<string, string | ArrayBuffer | Uint8Array<ArrayBufferLike>>[]

        Array of item objects mapping UTI strings to strings or raw bytes

      Returns boolean

      true if the write succeeded