Macro to copy text to clipboard



  • Hi,
    I am trying to send some text to clipboard without typing it in editor so that the selection is not cleared. There is this Scintilla command which is not working in my following macro:

    <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
        <Action type="1" message="2420" wParam="3" lParam="" sParam="abc" />
    </Macro>
    
    

    When I run the macro, it doesn’t do anything.
    Am I missing anything? Can anyone please help?

    Thank you,
    Karun



  • @Karun-Poudel ,

    Interesting. I had never tried that message in a macro before, but it doesn’t seem to work for me, either.

    When I use that same message in NppExec (sci_sendmsg SCI_COPYTEXT 3 "abc"), it does work and the clipboard gets populated with abc, which I can then paste.

    I turned on my Edit > Clipboard History, and verified it updates live when I do normal copy/paste; when I use the NppExec, the ClipboardHistory also updates; but when I run that message in the macro you showed, it doesn’t update the Clipboard history.

    Let’s see, going back to @dinkumoil’s post which mentioned the EU-FOSSA impact on macros, there is a link to this Feb 2019 commit, and SCI_COPYTEXT is not in the list of macro-allowed Scintilla commands. As that post and the commit message mentioned, the restricted list was implemented to avoid running “arbitrary scintilla commands”, but it didn’t give an indication of how they decided what was “safe” for a macro or not.

    So, for now, the SCI_COPYTEXT (2420) message will not work in Macros. You might consider a plugin like NppExec or PythonScript, which do not have the same restricted list of messages to work with.



  • Thanks @PeterJones, that’s insightful. I will try to convert my macro to NppExec commands.


Log in to reply