apparently changed names and optimized inputs

This commit is contained in:
Schrottkatze 2022-07-03 15:23:21 +02:00
parent cedebb4b6d
commit c695d803e0
2 changed files with 16 additions and 17 deletions

View file

@ -63,35 +63,35 @@ fn get_remote(display_name: Option<String>) -> XDisplay {
display
}
fn run_instruction(instruction: &str, display: &XDisplay) {
fn run_instruction(instruction: &str, dpy: &XDisplay) {
let instruction: Vec<&str> = instruction.split(' ').collect();
match instruction[0] {
"Delay" => thread::sleep(Duration::from_millis(instruction[1].parse().unwrap())),
"ButtonPress" => display.send_fake_buttonpress(instruction[1].parse().unwrap()),
"ButtonRelease" => display.send_fake_buttonrelease(instruction[1].parse().unwrap()),
"MotionNotify" => display
"ButtonPress" => dpy.send_fake_buttonpress(instruction[1].parse().unwrap()),
"ButtonRelease" => dpy.send_fake_buttonrelease(instruction[1].parse().unwrap()),
"MotionNotify" => dpy
.send_fake_motion_event(instruction[1].parse().unwrap(), instruction[2].parse().unwrap()),
"KeyCodePress" => display.send_fake_keypress_from_code(instruction[1].parse().unwrap()),
"KeyCodeRelease" => display.send_fake_keyrelease_from_code(instruction[1].parse().unwrap()),
"KeySymPress" => display.send_fake_keypress_from_keysym(instruction[1].parse().unwrap()),
"KeyCodePress" => dpy.send_fake_keypress_from_code(instruction[1].parse().unwrap()),
"KeyCodeRelease" => dpy.send_fake_keyrelease_from_code(instruction[1].parse().unwrap()),
"KeySymPress" => dpy.send_fake_keypress_from_keysym(instruction[1].parse().unwrap()),
"KeySymRelease" => {
display.send_fake_keyrelease_from_keysym(instruction[1].parse().unwrap())
dpy.send_fake_keyrelease_from_keysym(instruction[1].parse().unwrap())
}
"KeySym" => {
let key: Keysym = instruction[1].parse().unwrap();
display.send_fake_keypress_from_keysym(key);
display.send_fake_keyrelease_from_keysym(key);
dpy.send_fake_keypress_from_keysym(key);
dpy.send_fake_keyrelease_from_keysym(key);
}
"KeyStrPress" => {
display.send_fake_keypress_from_string(CString::new(instruction[1]).unwrap().as_bytes())
dpy.send_fake_keypress_from_string(CString::new(instruction[1]).unwrap().as_bytes())
}
"KeyStrRelease" => display
"KeyStrRelease" => dpy
.send_fake_keyrelease_from_string(CString::new(instruction[1]).unwrap().as_bytes()),
"KeyStr" => {
let keystring = CString::new(instruction[1]).unwrap();
display.send_fake_keypress_from_string(keystring.as_bytes());
display.send_fake_keyrelease_from_string(keystring.as_bytes());
dpy.send_fake_keypress_from_string(keystring.as_bytes());
dpy.send_fake_keyrelease_from_string(keystring.as_bytes());
}
"String" => {
println!("Strings are currently not supported.");