Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32clipboard.SetClipboardData sometimes crashes #16

Open
quintijn opened this issue Apr 27, 2024 · 1 comment
Open

win32clipboard.SetClipboardData sometimes crashes #16

quintijn opened this issue Apr 27, 2024 · 1 comment

Comments

@quintijn
Copy link
Collaborator

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...

quintijn added a commit that referenced this issue Apr 27, 2024
* try to get win32 function running... (solved after win32_postinstall ran without errors, cleaning up a lot of pywin32 installs was needed, see dictation-toolbox/natlink#193)
* simplified extenvvars, getFolderFromLibraryName,
* try to specify setClipboard function spurious error, (issue #16)
@quintijn
Copy link
Collaborator Author

Put the latest code in the master branch of dtactions. Not in pip yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant