49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
use enigo::{Enigo, Key, KeyboardControllable};
|
|
use std::thread;
|
|
use std::time::Duration;
|
|
use arboard::Clipboard;
|
|
|
|
#[tauri::command]
|
|
fn type_str(input: String) {
|
|
#[cfg(dev)]
|
|
println!(">: {}", input);
|
|
|
|
let mut enigo = Enigo::new();
|
|
let mut clipboard = Clipboard::new().unwrap();
|
|
|
|
// 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);
|
|
|
|
thread::sleep(Duration::from_millis(200));
|
|
|
|
// TODO: Multi-platform paste
|
|
#[cfg(not(dev))]{
|
|
enigo.key_down(Key::Control);
|
|
enigo.key_click(Key::Layout('v'));
|
|
enigo.key_up(Key::Control);
|
|
}
|
|
|
|
thread::sleep(Duration::from_millis(20));
|
|
|
|
// Close program
|
|
#[cfg(not(dev))]
|
|
std::process::exit(0);
|
|
|
|
}
|
|
|
|
fn main() {
|
|
// TODO: Set Window location on launch
|
|
tauri::Builder::default()
|
|
.invoke_handler(tauri::generate_handler![type_str])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|