mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Fix cmd pop-up on background clipclear on Windows
This commit is contained in:
+7
-1
@@ -5,9 +5,11 @@ package clip
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/go-boilerplate/security"
|
"github.com/rwinkhart/go-boilerplate/security"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CopyBytes copies a byte slice to the clipboard.
|
// CopyBytes copies a byte slice to the clipboard.
|
||||||
@@ -28,7 +30,11 @@ func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
|
|||||||
|
|
||||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||||
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
|
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
|
||||||
|
sysProcAttr := &syscall.SysProcAttr{CreationFlags: windows.CREATE_NO_WINDOW}
|
||||||
|
pasteCMD := exec.Command("powershell.exe", "-c", "Get-Clipboard")
|
||||||
|
pasteCMD.SysProcAttr = sysProcAttr
|
||||||
clearCMD := exec.Command("clip.exe")
|
clearCMD := exec.Command("clip.exe")
|
||||||
|
clearCMD.SysProcAttr = sysProcAttr
|
||||||
_ = back.WriteToStdin(clearCMD, nil, false)
|
_ = back.WriteToStdin(clearCMD, nil, false)
|
||||||
return exec.Command("powershell.exe", "-c", "Get-Clipboard"), clearCMD, nil
|
return pasteCMD, clearCMD, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user