Skip to content

Commit

Permalink
Merge pull request #7141 from radarhere/grabclipboardwin32
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 6, 2023
2 parents df873e3 + f67fcf1 commit 3568df8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,14 @@ PyImaging_GrabClipboardWin32(PyObject *self, PyObject *args) {
LPCSTR format_names[] = {"DIB", "DIB", "file", "png", NULL};

if (!OpenClipboard(NULL)) {
PyErr_SetString(PyExc_OSError, "failed to open clipboard");
return NULL;
// Maybe the clipboard is temporarily in use by another process.
// Wait and try again
Sleep(500);

if (!OpenClipboard(NULL)) {
PyErr_SetString(PyExc_OSError, "failed to open clipboard");
return NULL;
}
}

// find best format as set by clipboard owner
Expand Down

0 comments on commit 3568df8

Please sign in to comment.