def do_set_data(): if not EmptyClipboard(): self.set_err("failed to empty the clipboard") if not SetClipboardData(win32con.CF_UNICODETEXT, buf): #no need to warn here #set_clipboard_text() will try again return log("SetClipboardData(..) done") cleanup() ret[0] = True
def got_clipboard_lock(): EmptyClipboard() c = 0 for fmt, handle in image_formats.items(): log("do_set_clipboard_image: %s", format_name(fmt)) r = SetClipboardData(fmt, handle) if not r: e = WinError(GetLastError()) log("SetClipboardData(%s, %#x)=%s (%s)", format_name(fmt), handle, r, e) else: c += 1 return bool(c)
def set_clipboard_data(): r = EmptyClipboard() log("EmptyClipboard()=%s", r) if not r: self.set_err("failed to empty the clipboard") return False r = SetClipboardData(win32con.CF_UNICODETEXT, buf) if not r: e = WinError(GetLastError()) log("SetClipboardData(CF_UNICODETEXT, %i chars)=%s (%s)", wlen, r, e) return False log("SetClipboardData(CF_UNICODETEXT, %i chars)=%s", wlen, r) cleanup() return True
def empty_clipboard(self): r = EmptyClipboard() log("EmptyClipboard()=%s", r) return True