Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

Merge pull request #50 from vladstudio/cross-layout-paste

CJ Pais1c9b2ee7a176
diff --cc src-tauri/src/utils.rs
index a3d4c93d,e00a4d09..47b88a1d
--- a/src-tauri/src/utils.rs
+++ b/src-tauri/src/utils.rs
@@@ -12,17 -11,21 +12,21 @@@ use std::fs::File
use std::io::BufReader;
use std::thread;
use tauri::image::Image;
+use tauri::menu::{Menu, MenuItem, PredefinedMenuItem};
use tauri::tray::TrayIcon;
-use tauri::AppHandle;
-use tauri::Manager;
+use tauri::{AppHandle, Emitter, Manager, WebviewWindowBuilder};
use tauri_plugin_clipboard_manager::ClipboardExt;
+ /// Sends a paste command (Cmd+V or Ctrl+V) using platform-specific virtual key codes.
+ /// This ensures the paste works regardless of keyboard layout (e.g., Russian, AZERTY, DVORAK).
fn send_paste() -> Result<(), String> {
- // Determine the modifier key based on the OS
+ // Platform-specific key definitions
#[cfg(target_os = "macos")]
- let modifier_key = Key::Meta; // Command key on macOS
- #[cfg(not(target_os = "macos"))]
- let modifier_key = Key::Control; // Control key on other systems
+ let (modifier_key, v_key_code) = (Key::Meta, Key::Other(9));
+ #[cfg(target_os = "windows")]
+ let (modifier_key, v_key_code) = (Key::Control, Key::Other(0x56)); // VK_V
+ #[cfg(target_os = "linux")]
+ let (modifier_key, v_key_code) = (Key::Control, Key::Unicode('v'));
let mut enigo = Enigo::new(&Settings::default())
.map_err(|e| format!("Failed to initialize Enigo: {}", e))?;