Open at cursor location

This commit is contained in:
2023-07-23 18:08:38 -04:00
parent 47e6b2a125
commit 49b11741cb
5 changed files with 1051 additions and 14 deletions

View File

@@ -1,11 +1,18 @@
// 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 enigo::{Enigo, Key, KeyboardControllable, MouseControllable};
use std::thread;
use std::time::Duration;
use arboard::Clipboard;
#[tauri::command]
fn get_mouse_pos() -> String {
let enigo = Enigo::new();
let (x, y) = enigo.mouse_location();
format!("{{ \"x\": {}, \"y\": {} }}", x, y).into()
}
#[tauri::command]
fn type_str(input: String) {
#[cfg(dev)]
@@ -42,7 +49,8 @@ fn type_str(input: String) {
fn main() {
// TODO: Set Window location on launch
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![type_str])
.plugin(tauri_plugin_positioner::init())
.invoke_handler(tauri::generate_handler![type_str, get_mouse_pos])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}