pub struct VirtualDevice { /* private fields */ }

Implementations§

source§

impl VirtualDevice

source

pub fn new() -> Self

Examples found in repository?
examples/keyboard.rs (line 9)
8
9
10
11
12
13
14
15
16
17
18
fn main() {
    let mut device = VirtualDevice::new();

    thread::sleep(Duration::from_secs(2));

    // type hello
    for key in [KEY_H, KEY_E, KEY_L, KEY_L, KEY_O] {
        device.click(key).unwrap();
        // thread::sleep(Duration::from_millis(5));
    }
}
More examples
Hide additional examples
examples/mouse.rs (line 9)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let mut device = VirtualDevice::new();

    for _ in 1..5 {
        thread::sleep(Duration::from_secs(1));

        // scroll vertically by 100
        device.scroll_vertical(100).unwrap();
        // move cursor vertically from the current position by 50
        device.move_mouse(50, 50).unwrap();
        //click the left mouse button
        device.click(BTN_LEFT).unwrap();
    }
}
source

pub fn synchronize(&mut self) -> Result<(), Error>

source

pub fn move_mouse(&mut self, x: i32, y: i32) -> Result<(), Error>

Examples found in repository?
examples/mouse.rs (line 17)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let mut device = VirtualDevice::new();

    for _ in 1..5 {
        thread::sleep(Duration::from_secs(1));

        // scroll vertically by 100
        device.scroll_vertical(100).unwrap();
        // move cursor vertically from the current position by 50
        device.move_mouse(50, 50).unwrap();
        //click the left mouse button
        device.click(BTN_LEFT).unwrap();
    }
}
source

pub fn scroll_vertical(&mut self, value: i32) -> Result<(), Error>

Examples found in repository?
examples/mouse.rs (line 15)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let mut device = VirtualDevice::new();

    for _ in 1..5 {
        thread::sleep(Duration::from_secs(1));

        // scroll vertically by 100
        device.scroll_vertical(100).unwrap();
        // move cursor vertically from the current position by 50
        device.move_mouse(50, 50).unwrap();
        //click the left mouse button
        device.click(BTN_LEFT).unwrap();
    }
}
source

pub fn scroll_horizontal(&mut self, value: i32) -> Result<(), Error>

source

pub fn press(&mut self, button: u16) -> Result<(), Error>

source

pub fn release(&mut self, button: u16) -> Result<(), Error>

source

pub fn click(&mut self, button: u16) -> Result<(), Error>

Examples found in repository?
examples/keyboard.rs (line 15)
8
9
10
11
12
13
14
15
16
17
18
fn main() {
    let mut device = VirtualDevice::new();

    thread::sleep(Duration::from_secs(2));

    // type hello
    for key in [KEY_H, KEY_E, KEY_L, KEY_L, KEY_O] {
        device.click(key).unwrap();
        // thread::sleep(Duration::from_millis(5));
    }
}
More examples
Hide additional examples
examples/mouse.rs (line 19)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let mut device = VirtualDevice::new();

    for _ in 1..5 {
        thread::sleep(Duration::from_secs(1));

        // scroll vertically by 100
        device.scroll_vertical(100).unwrap();
        // move cursor vertically from the current position by 50
        device.move_mouse(50, 50).unwrap();
        //click the left mouse button
        device.click(BTN_LEFT).unwrap();
    }
}

Trait Implementations§

source§

impl Drop for VirtualDevice

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.