A cross-platform screenshots library for MacOS、Windows、Linux(X11、wayland).
```rust use screenshots::Screenshots; use std::{fs::File, io::Write, time::Instant};
fn main() { let start = Instant::now();
let screenshotss = Screenshots::all();
for screenshots in screenshotss { println!("capturer {:?}", screenshots); let image = screenshots.capture().unwrap(); let buffer = image.png().unwrap(); let displayid = screenshots.displayinfo.id.tostring(); let path = String::from("") + &displayid + ".png"; let mut file = File::create(path).unwrap(); file.write_all(&buffer[..]).unwrap(); }
let screenshots = Screenshots::from_point(100, 100).unwrap(); println!("capturer {:?}", screenshots);
let image = screenshots.capture().unwrap(); let buffer = image.png().unwrap(); let mut file = File::create("capturedisplaywithpoint.png").unwrap(); file.writeall(&buffer[..]).unwrap();
println!("运行耗时: {:?}", start.elapsed()); }
```