AutoType top level statuses
This commit is contained in:
34
src-tauri/src/main.rs
Normal file
34
src-tauri/src/main.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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;
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
#[tauri::command]
|
||||
fn type_str(input: String) {
|
||||
println!("Type this: {}", input);
|
||||
let mut enigo = Enigo::new();
|
||||
let mut clipboard = Clipboard::new().unwrap();
|
||||
clipboard.set_text(input).unwrap();
|
||||
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Control);
|
||||
thread::sleep(Duration::from_millis(20));
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![type_str])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
Reference in New Issue
Block a user