pc-remote 0.1.0

This library provides cross-platform control over computer input devices
Documentation

githubcrates-iodocs-rs

PC Remote Control Library

This library provides cross-platform control over computer input devices. It allows emulating keyboard and mouse inputs programmatically and managing audio devices. The library is designed for seamless integration into Rust projects, providing ergonomic APIs for all supported functionalities. Please ensure the utility binaries (nircmd.exe, SoundVolumeView.exe, svcl.exe) are present in your binary path for audio control.

Audio Device Management (for Windows OS only):

For audio device management, this library relies on several lightweight Windows utilities:

  • nircmd — for setting system volume.
  • SoundVolumeView (svv) — for managing default audio devices and mute/unmute operations.
  • SoundVolumeCommandLine (svcl) — for retrieving current volume and mute status.

These tools are efficient and minimal, allowing fast interactions with Windows audio system without complex API integrations. You can download these utilities bundled together here: https://github.com/fuderis/rs-pc-remote/raw/main/bin

Examples:

Keyboard Device Emulation:

use pc_remote::{ Result, Keyboard, Key };

fn main() -> Result<()> {
    let mut keyboard = Keyboard::new()?;

    let hotkey = [Key::Shift, Key::A];
    
    keyboard.press(&hotkey)?;
    keyboard.release(&hotkey)?;

    Ok(())
}

Mouse Device Emulation:

use pc_remote::{ Result, Mouse };

fn main() -> Result<()> {
    let mut mouse = Mouse::new()?;

    mouse.move_to_center()?;
    
    Ok(())
}

Media Devices Control:

use pc_remote::{ Result, Media };
use macron::path;

fn main() -> Result<()> {
    let media = Media::new(path!("bin/nirsoft"))?;

    /* binary repository example:
        /bin
            /nirsoft
                /nircmd/nircmd.exe
                /svcl/svcl.exe
                /svv/SoundVolumeView.exe
    */

    let audio_device = media.active_audio().expect("no audio device found");
    let micro_device = media.active_micro().expect("no micro device found");

    println!("Audio device: '{}', Microphone: '{}'", &audio_device.name, &micro_device.name);
    println!("Audio volume: {}%", audio_device.get_volume()?);

    audio_device.set_volume(10)?;
    println!("Audio volume: {}%", audio_device.get_volume()?);
    
    Ok(())
}

Feedback:

This library distributed under the MIT license.

You can contact me via GitHub or send a message to my telegram @fuderis. This library is actively evolving, and your suggestions and feedback are always welcome!