espanso/src/keyboard/windows.rs

39 lines
832 B
Rust
Raw Normal View History

use std::sync::mpsc;
use std::os::raw::{c_void};
use widestring::{U16CString};
use crate::bridge::windows::*;
2019-08-30 19:24:03 +00:00
pub struct WindowsKeyboardSender {
}
impl super::KeyboardSender for WindowsKeyboardSender {
fn send_string(&self, s: &str) {
let res = U16CString::from_str(s);
match res {
Ok(s) => {
unsafe {
send_string(s.as_ptr());
}
}
Err(e) => println!("Error while sending string: {}", e.to_string())
}
}
fn send_enter(&self) {
unsafe {
// Send the VK_RETURN key press
send_vkey(0x0D);
}
}
fn trigger_paste(&self) {
unimplemented!()
}
fn delete_string(&self, count: i32) {
2019-08-30 19:24:03 +00:00
unsafe {
delete_string(count)
2019-08-30 19:24:03 +00:00
}
}
}