[][src]Struct mouse_rs::Mouse

pub struct Mouse(_);

Struct for the mouse

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

Implementations

impl Mouse[src]

pub fn new() -> Mouse[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 mouse around

Examples

use mouse_rs::{types::keys::*, Mouse};

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

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

This method presses the given button in

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

Examples

use mouse_rs::{types::keys::Keys, Mouse};

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

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

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

This will release the button as noted above

pub fn get_position(&self) -> Result<Point, Box<dyn Error>>[src]

This gets the current mouse position

Example

use mouse_rs::Mouse;

fn get_post() {
    let mouse = Mouse::new();
    let pos = mouse.get_position().unwrap();
    println!("X = {}, Y = {}", pos.x, pos.y)
}

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::{types::keys::*, Mouse};

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

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

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

This is the exact same as wheel

pub fn click<'a>(&self, button: &'a Keys) -> Result<(), Box<dyn Error + 'a>>[src]

Auto Trait Implementations

impl RefUnwindSafe for Mouse

impl Send for Mouse

impl Sync for Mouse

impl Unpin for Mouse

impl UnwindSafe for Mouse

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.