[][src]Struct mouse_rs::winmouse::WinMouse

pub struct WinMouse { /* fields omitted */ }

Struct for the mouse in windows

This struct represents a windows mouse and doesn't hold any values

Implementations

impl WinMouse[src]

pub fn new() -> WinMouse[src]

This method creates a new mouse instance, must always be run before anything else

pub fn move_to(&self, x: i32, y: i32) -> Result<(), Box<dyn Error>>[src]

This method moves the windows mouse around

Examples

use mouse_rs::{
    winmouse::WinMouse,
    types::keys::*
};

fn move_mouse() {
    let mouse = WinMouse::new();
    mouse.move_to(500, 500).expect("Unable to move mouse");
}

pub fn press(&self, button: &str) -> Result<(), Box<dyn Error>>[src]

This method presses the given button in

NOTE: This doesn't release the button so it will keep pressing

Examples

use mouse_rs::{
    winmouse::WinMouse,
    types::keys::*
};

fn press_button() {
    let mouse = WinMouse::new();
    mouse.press(LEFT).expect("Unable to press button"); // This will keep pressing
}

fn press_and_release_button() {
    let mouse = WinMouse::new();
    mouse.press(RIGHT).expect("Unable to press button");
    mouse.release(RIGHT).expect("Unable to release button"); // This will press the right mouse quickly
}

pub fn release(&self, button: &str) -> Result<(), Box<dyn Error>>[src]

This will release the button as noted above

pub fn wheel(&self, delta: i32) -> Result<(), Box<dyn Error>>[src]

This will scroll the mouse,

For scrolling down use negative values, for scrolling up use positive values

Examples

use mouse_rs::{
    winmouse::WinMouse,
    types::keys::*
};

fn scroll_up() {
    let mouse = WinMouse::new();
    mouse.wheel(1);
}

fn scroll_down() {
    let mouse = WinMouse::new();
    mouse.wheel(-1);
}

pub fn scroll(&self, delta: i32) -> Result<(), Box<dyn Error>>[src]

This is the exact same as wheel

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.