• Login
Community
  • Login

Macro to copy text to clipboard

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 731 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K
    Karun Poudel
    last edited by Jun 8, 2021, 6:44 AM

    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

    P 1 Reply Last reply Jun 8, 2021, 1:18 PM Reply Quote 1
    • P
      PeterJones @Karun Poudel
      last edited by PeterJones Jun 8, 2021, 1:19 PM Jun 8, 2021, 1:18 PM

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

      1 Reply Last reply Reply Quote 3
      • K
        Karun Poudel
        last edited by Jun 8, 2021, 4:39 PM

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

        1 Reply Last reply Reply Quote 0
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors