1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use mouse_keyboard_input::*;
use std::thread;
use std::thread::JoinHandle;
use std::time::Duration;

fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
    thread::spawn(move || {
        for _ in 1..5 {
            thread::sleep(Duration::from_secs(1));

            // scroll vertically by 100
            VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
            // move cursor vertically from the current position by 50
            VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
            //click the left mouse button
            VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
        };
    })
}

fn main() {
    let device = VirtualDevice::default().unwrap();

    let sender = device.sender.clone();

    device.flush_channel_every_interval();

    write_events_in_thread(sender).join().unwrap();
}