Mouse

Struct Mouse 

Source
pub struct Mouse;
Expand description

A zero-sized structure that wraps functions related to the mouse.

Implementations§

Source§

impl Mouse

Source

pub fn position() -> Result<(i32, i32), WindowsError>

Retrieve the current position of the mouse, in screen coordinates.

§Example
use winput::Mouse;

println!("The mouse is at {:?}", Mouse::position());
Source

pub fn set_position(x: i32, y: i32) -> Result<(), WindowsError>

Sets the position of the mouse, in screen coordinates.

§Example
use winput::{Vk, Mouse};

Mouse::set_position(50, 50).unwrap();
Source

pub fn scroll(amount: f32)

Synthesizes a vertical scroll event.

If the function fails to synthesize the input, no error is emited and the function fails silently. If you wish to retreive an eventual error, use send_inputs instead.

§Example
use winput::Mouse;

Mouse::scroll(1.0).unwrap();
Source

pub fn scrollh(amount: f32)

Synthesizes a horizontal scroll event.

If the function fails to synthesize the input, no error is emited and the function fails silently. If you wish to retreive an eventual error, use send_inputs instead.

§Example
use winput::Mouse;

Mouse::scrollh(1.0).unwrap();
Source

pub fn move_relative(dx: i32, dy: i32)

Moves the mouse relatively to its current position, in screen coordinates.

If the function fails to synthesize the input, no error is emited and the function fails silently. If you wish to retreive an eventual error, use send_inputs instead.

§Example
use winput::Mouse;

Mouse::move_relative(100, 50).unwrap();
Source

pub fn move_absolute(x: f32, y: f32)

Moves the mouse using absolute normalized coordinates.

If the function fails to synthesize the input, no error is emited and the function fails silently. If you wish to retreive an eventual error, use send_inputs instead.

§Example
use winput::Mouse;

// Move the mouse in the center of the main monitor.
Mouse::move_absolute(0.5, 0.5).unwrap();

Auto Trait Implementations§

§

impl Freeze for Mouse

§

impl RefUnwindSafe for Mouse

§

impl Send for Mouse

§

impl Sync for Mouse

§

impl Unpin for Mouse

§

impl UnwindSafe for Mouse

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.