Community
    • Login

    Macro to copy text to clipboard

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 727 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.
    • Karun PoudelK
      Karun Poudel
      last edited by

      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

      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @Karun Poudel
        last edited by PeterJones

        @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
        • Karun PoudelK
          Karun Poudel
          last edited by

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

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