fix: 修复 Windows 上 Ctrl+V 粘贴失效,改用 KeyDown/KeyUp 手动控制修饰键
This commit is contained in:
@@ -43,13 +43,20 @@ func ClipboardOnly(text string) {
|
||||
}
|
||||
|
||||
func simulatePaste() error {
|
||||
var modifier, key string
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
robotgo.KeyTap("v", "command")
|
||||
modifier, key = "command", "v"
|
||||
case "linux", "windows":
|
||||
robotgo.KeyTap("v", "control")
|
||||
modifier, key = "ctrl", "v"
|
||||
default:
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user