# clipboard-windows **Repository Path**: yuanliwei/clipboard-windows ## Basic Information - **Project Name**: clipboard-windows - **Description**: A Node.js native addon for accessing Windows clipboard, supporting text and image operations - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-31 - **Last Updated**: 2026-02-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # clipboard-windows **clipboard-windows:** Windows Clipboard Access for Node.js A Node.js native addon written in Rust for accessing Windows clipboard, supporting text and image operations. This project was bootstrapped by [create-neon](https://www.npmjs.com/package/create-neon). ## Features - Read and write text to/from clipboard - Read and write images to/from clipboard (supports PNG, JPEG, GIF, BMP formats) - Read HTML content from clipboard - TypeScript support with type definitions ## Installation ```sh npm install clipboard-windows ``` ## Usage ```javascript import { readClipboard, writeClipboard, readClipboardText, writeClipboardText, readClipboardImage, readClipboardHtml } from 'clipboard-windows'; // Write text to clipboard writeClipboardText('Hello, World!'); // Read text from clipboard const text = readClipboardText(); console.log(text); // Write image to clipboard (supports PNG, JPEG, GIF, BMP) import { readFileSync } from 'fs'; const imageBuffer = readFileSync('image.png'); writeClipboard('image', imageBuffer); // Read clipboard contents with type detection const clipboardData = readClipboard(); console.log(clipboardData.type); // 'text', 'richtext', or 'image' console.log(clipboardData.data); // actual data // Read image from clipboard (returns PNG buffer) const image = readClipboardImage(); ``` ## Building clipboard-windows Building clipboard-windows requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support). To run the build, run: ```sh $ npm run build ``` This command uses the [@neon-rs/cli](https://www.npmjs.com/package/@neon-rs/cli) utility to assemble the binary Node addon from the output of `cargo`. ## Exploring clipboard-windows After building clipboard-windows, you can explore its exports at the Node console: ```sh $ npm i $ npm run build $ node > require('.').hello('node') 'hello node' ``` ## Available Scripts In the project directory, you can run: #### `npm install` Installs the project, including running `npm run build`. #### `npm run build` Builds the Node addon (`index.node`) from source, generating a release build with `cargo --release`. Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to `npm run build` and similar commands. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html): ``` npm run build -- --feature=beetle ``` #### `npm run debug` Similar to `npm run build` but generates a debug build with `cargo`. #### `npm run cross` Similar to `npm run build` but uses [cross-rs](https://github.com/cross-rs/cross) to cross-compile for another platform. Use the [`CARGO_BUILD_TARGET`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) environment variable to select the build target. #### `npm test` Runs the unit tests by calling `cargo test` and Node.js tests. You can learn more about [adding tests to your Rust code](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) from the [Rust book](https://doc.rust-lang.org/book/). #### `npm run clean` Clean the build artifacts. ## Project Layout The directory structure of this project is: ``` clipboard-windows/ ├── Cargo.toml ├── README.md ├── src/ | └── lib.rs ├── index.node ├── package.json └── target/ ``` | Entry | Purpose | |----------------|------------------------------------------------------------------------------------------------------------------------------------------| | `Cargo.toml` | The Cargo [manifest file](https://doc.rust-lang.org/cargo/reference/manifest.html), which informs the `cargo` command. | | `README.md` | This file. | | `src/` | The directory tree containing the Rust source code for the project. | | `lib.rs` | Entry point for the Rust source code. | | `index.node` | The main module, a [Node addon](https://nodejs.org/api/addons.html) generated by the build and pointed to by `"main"` in `package.json`. | | `package.json` | The npm [manifest file](https://docs.npmjs.com/cli/v7/configuring-npm/package-json), which informs the `npm` command. | | `target/` | Binary artifacts generated by the Rust build. | ## Learn More Learn more about: - [Neon](https://neon-bindings.com). - [Rust](https://www.rust-lang.org). - [Node](https://nodejs.org).