fix: 修复 Windows 上 Ctrl+V 粘贴失效,改用 KeyDown/KeyUp 手动控制修饰键

This commit is contained in:
2026-03-01 04:27:15 +08:00
parent 75abe72bf6
commit 193f208d80

View File

@@ -43,13 +43,20 @@ func ClipboardOnly(text string) {
} }
func simulatePaste() error { func simulatePaste() error {
var modifier, key string
switch runtime.GOOS { switch runtime.GOOS {
case "darwin": case "darwin":
robotgo.KeyTap("v", "command") modifier, key = "command", "v"
case "linux", "windows": case "linux", "windows":
robotgo.KeyTap("v", "control") modifier, key = "ctrl", "v"
default: default:
return fmt.Errorf("unsupported platform: %s", runtime.GOOS) return fmt.Errorf("unsupported platform: %s", runtime.GOOS)
} }
robotgo.KeyDown(modifier)
time.Sleep(20 * time.Millisecond)
robotgo.KeyTap(key)
time.Sleep(20 * time.Millisecond)
robotgo.KeyUp(modifier)
return nil return nil
} }