#virtual #desktop #accessing #bindings #11 #api #com

winvd

Provides functions for accessing Windows 11 virtual desktop API, requires at least 22621 build

28 releases

0.0.46 Jan 25, 2024
0.0.45 Nov 11, 2023
0.0.40 Aug 31, 2023
0.0.30 Feb 26, 2023
0.0.3 Jun 30, 2020

#306 in GUI

Download history 5/week @ 2024-01-21 29/week @ 2024-02-25 4/week @ 2024-03-10 1/week @ 2024-03-17 372/week @ 2024-03-31

377 downloads per month
Used in tileme

MIT license

87KB
2K SLoC

winvd - Windows 11 virtual desktop bindings for Rust

The implementation abstracts the annoying COM API into simple functions.

https://crates.io/crates/winvd https://github.com/ciantic/VirtualDesktopAccessor/tree/rust/

Example

use winvd::{switch_desktop, get_desktop_count, DesktopEvent, listen_desktop_events};

fn main() {
    // Desktop count
    println!("Desktops: {:?}", get_desktop_count().unwrap());

    // Go to second desktop, index = 1
    switch_desktop(1).unwrap();

    // To listen for changes, use crossbeam, mpsc or winit proxy as a sender
    let (tx, rx) = std::sync::mpsc::channel::<DesktopEvent>();
    let _notifications_thread = listen_desktop_events(tx);

    // Keep the _notifications_thread alive for as long as you wish to listen changes
    std::thread::spawn(|| {
        for item in rx {
            println!("{:?}", item);
        }
    });

    // Wait for keypress
    println!("⛔ Press enter to stop");
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
}

WIP see more examples from the testbin sources 🢅.

Notes

cargo clean
cargo doc --all-features
cargo build --release --workspace

Dependencies

~161MB
~2.5M SLoC