Fix Windows Method #41
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Windows method was a bit unstable on my system, so I decided to rewrite it in the most cautious way possible based on the MSDN docs
GlobalAllocis called withGMEM_MOVEABLEas required bySetClipboardDataOpenClipboard, as required by the SetClipboardData docsOpenClipboardfails the first time, we repeatedly try to get the clipboard lock for up to 500ms.HANDLEapparently as different sizes on x32 and x64, thus we must specify argtypes and restype for each API call).decode('mbcs')call. On Python 2.7, c_wchar_p apparently auto-converts bytes to unicode. On Python 3.5, calling the method with bytes returns a fairly descriptiveTypeError: unicode string or integer address expected instead of bytes instanceerror. If there are issues with that, there should be tests to cover this.This should fix #5, fix #7, fix #10, fix #16, fix #21, fix #25.
It should also fix #27 and #35 by making them obsolete.