Multi-platform support!
This commit is contained in:
@@ -24,15 +24,40 @@ fn type_str(input: String) {
|
||||
// Load input into clipboard
|
||||
clipboard.set_text(input).unwrap();
|
||||
|
||||
// TODO: Multi-platform window switch
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
// TODO: Set the Command/Alt key configured by user
|
||||
#[cfg(target_os = "macos")] {
|
||||
enigo.key_down(Key::Command);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Command);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")] {
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")] {
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
|
||||
// TODO: Multi-platform paste
|
||||
#[cfg(not(dev))]{
|
||||
#[cfg(target_os = "windows")]{
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Control);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]{
|
||||
enigo.key_down(Key::Command);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Command);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]{
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Control);
|
||||
@@ -47,7 +72,6 @@ fn type_str(input: String) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// TODO: Set Window location on launch
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_positioner::init())
|
||||
.invoke_handler(tauri::generate_handler![type_str, get_mouse_pos])
|
||||
|
Reference in New Issue
Block a user