mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
source code
This commit is contained in:
11
libs/enigo/examples/dsl.rs
Normal file
11
libs/enigo/examples/dsl.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use enigo::{Enigo, KeyboardControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
let mut enigo = Enigo::new();
|
||||
|
||||
// write text and select all
|
||||
enigo.key_sequence_parse("{+UNICODE}{{Hello World!}} ❤️{-UNICODE}{+CTRL}a{-CTRL}");
|
||||
}
|
||||
12
libs/enigo/examples/key.rs
Normal file
12
libs/enigo/examples/key.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use enigo::{Enigo, Key, KeyboardControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
let mut enigo = Enigo::new();
|
||||
|
||||
enigo.key_down(Key::Layout('a'));
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
enigo.key_up(Key::Layout('a'));
|
||||
}
|
||||
16
libs/enigo/examples/keyboard.rs
Normal file
16
libs/enigo/examples/keyboard.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use enigo::{Enigo, Key, KeyboardControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
let mut enigo = Enigo::new();
|
||||
|
||||
// write text
|
||||
enigo.key_sequence("Hello World! here is a lot of text ❤️");
|
||||
|
||||
// select all
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('a'));
|
||||
enigo.key_up(Key::Control);
|
||||
}
|
||||
37
libs/enigo/examples/mouse.rs
Normal file
37
libs/enigo/examples/mouse.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use enigo::{Enigo, MouseButton, MouseControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let wait_time = Duration::from_secs(2);
|
||||
let mut enigo = Enigo::new();
|
||||
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_move_to(500, 200);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_down(MouseButton::Left);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_move_relative(100, 100);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_up(MouseButton::Left);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_click(MouseButton::Left);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_scroll_x(2);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_scroll_x(-2);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_scroll_y(2);
|
||||
thread::sleep(wait_time);
|
||||
|
||||
enigo.mouse_scroll_y(-2);
|
||||
thread::sleep(wait_time);
|
||||
}
|
||||
22
libs/enigo/examples/timer.rs
Normal file
22
libs/enigo/examples/timer.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use enigo::{Enigo, Key, KeyboardControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() {
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
let mut enigo = Enigo::new();
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
// write text
|
||||
enigo.key_sequence("Hello World! ❤️");
|
||||
|
||||
let time = now.elapsed();
|
||||
println!("{:?}", time);
|
||||
|
||||
// select all
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('a'));
|
||||
enigo.key_up(Key::Control);
|
||||
}
|
||||
Reference in New Issue
Block a user