-
Notifications
You must be signed in to change notification settings - Fork 144
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
added watcher functionality #31
base: master
Are you sure you want to change the base?
Conversation
Hi @shivylp, first thanks for implementing this feature! I'm using your fork in my current project and have some issues on Windows when copying an file before starting the application. I'll always get an error from getClipboardData.Call(cfUnicodetext) in clipboard_windows.go. I think this is not a problem of your pull request but initially you're setting the currentValue and return if an error occurs. Sadly I can't get this return value when using Goroutines. Or am i wrong? https://github.com/atotto/clipboard/pull/31/files#diff-f523429d86f9f4660c4360d3d046cee7R27 I'm calling your monitor method in my project at this line and have no access to an error. To solve this problem I've made this changes.
|
You can probably do: go func(){
if err := Monitor(....); err != nil {
// some way to handle this error
}
}() If that doesn't work for you, the logic of the The first error check was there to ensure this function does not set off an infinite for-loop that doesn't do anything. If the first time |
I'm of your opinion if the error is not produced by a value in the clipboard like init clipboard. But in my case I want to have that infinite for-loop because at first there is an invalid value for example a copied file but then I copy another value which would replace it successfully. Just this error or other errors will be ignored inside of the infinite for-loop. So maybe it is possible to distinguish these error types? For now I've copied your logic of the |
Did not see this implementation and reimplemeted it. Now that I'm done I'm gonna make a PR anyway: #38 |
Monitor()
function which watches the clipboard for changes usingReadAll()
function