Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear clipboard Error in clipboard_windows.go #68

Open
MangataTS opened this issue Sep 20, 2023 · 0 comments
Open

clear clipboard Error in clipboard_windows.go #68

MangataTS opened this issue Sep 20, 2023 · 0 comments

Comments

@MangataTS
Copy link

problem

When I repeatedly read the clipboard and then clear the clipboard, the clipping operation fails and the content cannot be read.

solved

I guessed that the problem might be that I used the writeAll function and passed in an empty string, so I added a new function: clearAll

func clearAll() error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	err := waitOpenClipboard()
	if err != nil {
		return err
	}

	r, _, err := emptyClipboard.Call(0)
	_, _, _ = closeClipboard.Call()
	if r == 0 {
		return err
	}
	return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant