Skip to content

clear clipboard Error in clipboard_windows.go  #68

@MangataTS

Description

@MangataTS

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions