Skip to content

Add function for getting clipboard text into string variable #106

@sasumner

Description

@sasumner

If I want my Pythonscript to get the Windows clipboard text (for a purpose other than putting said text into the current document), I either have to write some ctypes code that directly handles the clipboard, or I have to editor.paste() the text into a document, figure out how the paste changed the document (so that I can get the pasted text's length, and then its value), and then editor.undo() the change.

The downside of the ctypes approach: The code is longish, and there's some complications when the source for the clipboard text is from a CMD.exe window, and in general: Ugh!

The downside of the editor.paste() approach: To avoid having the paste text in the current document's redo history (after the undo), one has to create a temporary "new" file--this is slow and presents a visually negative screen flash to the user

The suggestion is to create a new function, suggested name of notepad.getClipboardText(). This function would obtain the clipboard text, with line-endings in the data that follow the active document's, and then return a string with the data. If the clipboard doesn't contain text data then an empty string should be returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions