Skip to content

win32clipboard.SetClipboardData sometimes crashes #16

Open
@quintijn

Description

@quintijn

In dtactions/unimacro/unimacroutils.py I have a function setClipboard:

def setClipboard(t, format=1):
    """set clipboard with text
    format = win32con.CF_UNICODETEXT (13): as unicode

    """
    #pylint:disable=W0622
    try:
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardData(format, t)
    except:
        print(f'exception in unimacroutils/setClipboard of "{t}"')
    finally:
        win32clipboard.CloseClipboard()

which works most of the time, but raises an exception (which cannot be caught, but crashes Dragon) with for example the second number:
(this is done via a function in dtactions\unimacro\unimacroactions.py, line 1120).

def try_SCLIP():
    ''' try by running this script, ensure cursor is on a safe place (bottom, or here after a #
    '''
    do_SCLIP('hello')
    print('try first number:')
    do_SCLIP('9123454321')
    # now comes the error:
    print('try second number:')
    do_SCLIP('123456789')
    print('ready')

I am puzzled...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions