mouse/
mouse.rs

1use mouse_keyboard_input::VirtualDevice;
2use mouse_keyboard_input::key_codes::*;
3use std::thread;
4use std::time::Duration;
5
6fn main() {
7    let mut device = VirtualDevice::default().unwrap();
8
9    for _ in 1..3 {
10        thread::sleep(Duration::from_secs(1));
11
12        // gradually scroll down by 100
13        device.smooth_scroll(0, -100).unwrap();
14        // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15        device.smooth_move_mouse(250, 250).unwrap();
16        //click the left mouse button
17        device.click(BTN_RIGHT).unwrap();
18    }
19
20    for _ in 1..2 {
21        thread::sleep(Duration::from_secs(1));
22
23        // scroll down by 100
24        device.scroll_y(-100).unwrap();
25        // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26        device.move_mouse(250, 250).unwrap();
27        //click the left mouse button
28        device.click(BTN_RIGHT).unwrap();
29    }
30}