examples/hello: improve hello world example
This commit is contained in:
parent
c743be9596
commit
5479de6a02
29
examples/hello.rs
Normal file
29
examples/hello.rs
Normal file
@ -0,0 +1,29 @@
|
||||
extern crate uinput;
|
||||
use uinput::event::keyboard;
|
||||
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let mut device = uinput::default().unwrap()
|
||||
.name("test").unwrap()
|
||||
.event(uinput::event::Keyboard::All).unwrap()
|
||||
.create().unwrap();
|
||||
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
|
||||
device.click(&keyboard::Key::H).unwrap();
|
||||
device.click(&keyboard::Key::E).unwrap();
|
||||
device.click(&keyboard::Key::L).unwrap();
|
||||
device.click(&keyboard::Key::L).unwrap();
|
||||
device.click(&keyboard::Key::O).unwrap();
|
||||
device.click(&keyboard::Key::Space).unwrap();
|
||||
device.click(&keyboard::Key::W).unwrap();
|
||||
device.click(&keyboard::Key::O).unwrap();
|
||||
device.click(&keyboard::Key::R).unwrap();
|
||||
device.click(&keyboard::Key::L).unwrap();
|
||||
device.click(&keyboard::Key::D).unwrap();
|
||||
device.click(&keyboard::Key::Enter).unwrap();
|
||||
|
||||
device.synchronize().unwrap();
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
extern crate uinput;
|
||||
use uinput::event::keyboard;
|
||||
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let mut device = uinput::default().unwrap()
|
||||
.name("test").unwrap()
|
||||
.event(uinput::event::keyboard::Key::K).unwrap()
|
||||
.create().unwrap();
|
||||
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
|
||||
device.press(keyboard::Key::K).unwrap();
|
||||
device.release(keyboard::Key::K).unwrap();
|
||||
device.synchronize().unwrap();
|
||||
}
|
Loading…
Reference in New Issue
Block a user