Community
    • Login

    Macro problem

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 129 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.
    • guy038G
      guy038
      last edited by guy038

      Hello, All,

      I need your help for a macro problem !

      On my portable v8.9 release of N++, I installed three plugins ComparePlus, Columns++ and NppUISpy

      I have two files, one in each N++ view .

      • In the main view, I have a list of regexes, in a txt file, in order to count the number of chars of any Unicode block. For instance :
      [\x{0000}-\x{007F}]      |     128  |  Basic Latin
      [\x{0080}-\x{00FF}]      |     128  |  Latin-1 Supplement
      [\x{0100}-\x{017F}]      |          |  Latin Extended-A
      [\x{0180}-\x{024F}]      |          |  Latin Extended-B
      [\x{0250}-\x{02AF}]      |          |  IPA Extensions
      [\x{02B0}-\x{02FF}]      |          |  Spacing Modifier Letters
      ...
      ...
      
      • In the secondary view, I have the Total_Chars.txt file, in N++ read-only mode, which contains all Unicode characters, minus the empty Unicode planes and few other zones

      So my goal is :

      • First, I select a regex, in the main view

      • Then, the macro :

        • Do the Copy action

        • Switch from main to secondary view

        • Open the Search dialog of the Columns++ plugin

        • Do the Paste action within the plugin dialog

      Here are the contents of this macro :

              <Macro name="Blocks" Ctrl="no" Alt="no" Shift="no" Key="0">
                  <Action type="0" message="2178" wParam="0" lParam="0" sParam=""/>
                  <Action type="2" message="0" wParam="44072" lParam="0" sParam=""/>
                  <Action type="2" message="0" wParam="22061" lParam="0" sParam=""/>
                  <Action type="0" message="2179" wParam="0" lParam="0" sParam=""/>
              </Macro>
      

      However, the Paste action does not occur and the search zone of the plugin is not updated with the clipboard contents :-((

      I also wanted, if possible, to get the total of chars, by hitting the Alt + T shortcut, within the Search dialog of the plugin

      Is there a mean to achieve such a goal ?

      TIA !

      Best Regards,

      guy038

      P.S. :

      Of course, the paste action is not allowed within the Total_Chars.txt file which is a read-only file !

      But, when I added a new tab in the secondary view, it does paste the text in this new tab, and NOT within the Find what field of the Columns++ plugin !

      Thomas KnoefelT mpheathM 2 Replies Last reply Reply Quote 0
      • Thomas KnoefelT
        Thomas Knoefel @guy038
        last edited by Thomas Knoefel

        @guy038
        Yeah, macros can’t interact with plugin dialogs - that’s a Notepad++ limitation.

        MultiReplace might work as an alternative

        What it can do: Instead of counting one regex at a time via a macro loop, MultiReplace lets you run all your regexes against the file in a single “Find All” operation, No macro gymnastics needed.

        Here’s the quick rundown:

        1. Open MultiReplace, right-click list header → enable “Find Count”
        2. Add your regexes (with Regex checkbox enabled), or import via CSV:
        Selected,Find,Replace,WholeWord,MatchCase,UseVariables,Extended,Regex,Comments
        1,"[\x{0000}-\x{007F}]","",0,0,0,0,1,Basic Latin
        1,"[\x{0080}-\x{00FF}]","",0,0,0,0,1,Latin-1 Supplement
        
        1. Open Total_Chars.txt, click “Find All”

        The Find Count column shows all matches at once. Works with read-only files.

        The catch: it’s batch, not interactive. And the counts aren’t in CSV export yet - you’d copy them manually. (That feature is on my list right now.)

        Cheers

        1 Reply Last reply Reply Quote 1
        • mpheathM
          mpheath @guy038
          last edited by

          @guy038

          https://www.scintilla.org/ScintillaDoc.html#SCI_COPY

          copying data to the clipboard

          Is document to the clipboard.

          https://www.scintilla.org/ScintillaDoc.html#SCI_PASTE

          pasting from the clipboard into the document

          Is clipboard to the document.

          Both functions relate to the document in the editor. The copy function will be good for the task though paste will not work with the search window.

          Instead of SCI_PASTE, could use the Run command to run an executable to insert the clipboard text into the search window.

          AutoIt3 script automate_columns++_search.au3 :

          ; Wait up to 3 seconds for the window.
          $hSearch = WinWait('Search in indicated region', '', 3)
          
          If $hSearch Then
              $sClip = ClipGet()  ; get clipboard text
              ControlSetText($hSearch, '', 'Edit1', $sClip)  ; set combo edit
              ControlClick($hSearch, '', 'Button7')  ; click regex button
              ControlClick($hSearch, '', 'Button9')  ; click count button
              $sCount = ControlGetText($hSearch, '', 'Static3')  ; read label
              ClipPut($sCount)  ; set clipboard text
          EndIf
          

          Adjust the title if the window text is localized.

          Compile to executable and then add to Run as a command. Get the command id with NppUISpy and insert into the shortcuts.xml file.

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