https://github.com/ayangweb/tauri-plugin-screenshots
Get screenshots of windows and monitors.
https://github.com/ayangweb/tauri-plugin-screenshots
Last synced: 3 months ago
JSON representation
Get screenshots of windows and monitors.
- Host: GitHub
- URL: https://github.com/ayangweb/tauri-plugin-screenshots
- Owner: ayangweb
- License: mit
- Created: 2025-02-27T14:31:51.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-02-27T15:00:28.000Z (3 months ago)
- Last Synced: 2025-02-27T18:30:49.948Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 242 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-tauri - tauri-plugin-screenshots - Get screenshots of windows and monitors. (Development / Plugins)
README
# tauri-plugin-screenshots
> This plugin only works on tauri v2, if you need the v1 plugin, feel free to submit a PR!
Get screenshots of windows and monitors.
https://github.com/user-attachments/assets/0cc6e2ea-cf85-41ed-a809-078393a95c0f
## Install
```shell
cargo add tauri-plugin-screenshots
```You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
```shell
pnpm add tauri-plugin-screenshots-api
```## Usage
`src-tauri/src/lib.rs`
```diff
pub fn run() {
tauri::Builder::default()
+ .plugin(tauri_plugin_screenshots::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
````src-tauri/capabilities/default.json`
```diff
{
...
"permissions": [
...
+ "screenshots:default"
]
}
```Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```ts
import {
getScreenshotableWindows,
getWindowScreenshot,
} from "tauri-plugin-screenshots-api";const windows = await getScreenshotableWindows();
const path = await getWindowScreenshot(windows[0].id);
console.log(path); // xx/tauri-plugin-screenshots/window-{id}.png
```## Methods
| Method | Description |
| --------------------------- | ------------------------------------------------------- |
| `getScreenshotableWindows` | Get all windows that can take screenshots. |
| `getScreenshotableMonitors` | Get all monitors that can take screenshots. |
| `getWindowScreenshot` | Get a screenshot of the window with the specified id. |
| `getMonitorScreenshot` | Get a screenshot of the monitors with the specified id. |
| `removeWindowScreenshot` | Remove locally stored window screenshots. |
| `removeMonitorScreenshot` | Remove locally stored monitor screenshots. |
| `clearScreenshots` | Remove all locally stored screenshots. |## Example
```shell
git clone https://github.com/ayangweb/tauri-plugin-screenshots.git
``````shell
pnpm installpnpm build
cd examples/tauri-app
pnpm install
pnpm tauri dev
```## Thanks
- Use [xcap](https://github.com/nashaofu/xcap) to get window and monitor screenshots.
## Who's Using It?
- [Coco AI](https://github.com/infinilabs/coco-app) - Search, Connect, Collaborate, Your Personal AI Search and Assistant, all in one space.