Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196288 > unrolled thread

Re: win32clipboard writing to clipboard on Windows 11

Started byEryk Sun <eryksun@gmail.com>
First post2024-06-18 02:26 -0500
Last post2024-06-18 02:26 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: win32clipboard writing to clipboard on Windows 11 Eryk Sun <eryksun@gmail.com> - 2024-06-18 02:26 -0500

#196288 — Re: win32clipboard writing to clipboard on Windows 11

FromEryk Sun <eryksun@gmail.com>
Date2024-06-18 02:26 -0500
SubjectRe: win32clipboard writing to clipboard on Windows 11
Message-ID<mailman.152.1718695638.2909.python-list@python.org>
On Tue, Jun 18, 2024 at 2:19 AM Eryk Sun <eryksun@gmail.com> wrote:
>
>
>     def set_clipboard_text(text):
>         hMem = global_alloc_text(text)
>         try:
>             win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT,
>                                             hMem)
>             # Now the system owns the global memory.
>         except:
>             kernel32.GlobalFree(hMem)

Oops, that suppresses the exception. Fixed:

    def set_clipboard_text(text):
        hMem = global_alloc_from_text(text)
        try:
            win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT,
                                            hMem)
            # Now the system owns the global memory.
        except:
            kernel32.GlobalFree(hMem)
            raise

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web