Community
    • 登入

    Output to Clipboard of "Count" function in search panel

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    12 貼文 3 Posters 5.7k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Ed BernasconiE
      Ed Bernasconi
      最後由 編輯

      Is there an way of getting the numeric result of the the search panel “Count” function (Alt+T) to be sent to the Clipboard?

      Thank you for your help!

      Ed

      Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
      • Claudia FrankC
        Claudia Frank @Ed Bernasconi
        最後由 編輯

        @Ed-Bernasconi

        collapse all and reopen first branch. Now you should see the lines
        Search …
        and all lines which do have matches.

        Use the mouse to select the lines in question and press CTRL+C.
        It does now have the whole output, including the in the number of matches in the clipboard.

        Cheers
        Claudia

        Ed BernasconiE 1 條回覆 最後回覆 回覆 引用 0
        • Ed BernasconiE
          Ed Bernasconi @Claudia Frank
          最後由 編輯

          @Claudia-Frank
          Thank you and Happy New!
          But you’ll have to explain to a newbie. Collapse what? And reopen the first branch of what? And so on… just imagine that I know nothing, which is not far from the truth.

          Thank you for your time!
          Ed

          Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
          • Claudia FrankC
            Claudia Frank @Ed Bernasconi
            最後由 編輯

            @Ed-Bernasconi

            thank you and Happy New Year to you as well.

            To collapse right-click in search result window

            and then click on the plus sign of Search … line to open first branch

            and now select the lines using the mouse and press CTRL+C
            (DO NOT USE the copy function from the context menu you see in the first image)
            Example shows I’ve pasted it in the editor above.

            Cheers
            Claudia

            Scott SumnerS 1 條回覆 最後回覆 回覆 引用 0
            • Scott SumnerS
              Scott Sumner @Claudia Frank
              最後由 編輯

              @Claudia-Frank

              It works but since it is a manual process I think I would just run the normal “count” button, make a mental note of what is reported in the status bar of the Find window, then retype that number wherever I need it. Or, retype it once, and copy THAT to the clipboard… :-)

              Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
              • Claudia FrankC
                Claudia Frank @Scott Sumner
                最後由 編輯

                @Scott-Sumner

                Scott, Happy New Year - do you gently try to tell me that I’m barking the wrong tree?
                If so, aahhhhh - I thought OP asked for the counts in search result window and not
                the count result from the button in normal find dialog.

                Well, it’s early in the year so it only can get better ;-D

                Cheers
                Claudia

                Scott SumnerS 1 條回覆 最後回覆 回覆 引用 0
                • Scott SumnerS
                  Scott Sumner @Claudia Frank
                  最後由 編輯

                  @Claudia-Frank

                  I guess we don’t know, truly, unless the OP replies and clarifies the real need. Sometimes the hardest thing is understanding or getting to the root of what people are trying to do–this can be more difficult than coming up with an actual solution. :-)

                  1 條回覆 最後回覆 回覆 引用 0
                  • Ed BernasconiE
                    Ed Bernasconi
                    最後由 編輯

                    hello Claudia and Scott,
                    The purpose is as follows.
                    I am trying to write a macro (in Macro Scheduler) where, at some point, I need a loop that will run X times, the X being the result of a count in the search window. This result varies, depending on the file being treated.
                    Thus, for example, if a search/count on “<a href”" gives 21 as a result, I need to reiterate the loop 21 times. It would be convenient to be able to transfer the 21 from the count result as a “Let T=21” in the macro and count down to know when to exit. The next time the result may be 37, needing 37 reiterations of the loop,
                    Any idea? Or, do you know of a plugin that might do the job?

                    Thank you both.
                    Ed

                    Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
                    • Claudia FrankC
                      Claudia Frank @Ed Bernasconi
                      最後由 編輯

                      @Ed-Bernasconi

                      Hello Ed,

                      no, I don’t know of any plugin who can interact with Macro Scheduler.
                      In addition I don’t know Macro Scheduler at all and how it is working.
                      For example, can it get values from Clipboard?
                      I personally would try to solve this using python script.
                      A script like this

                      search_term = 'def'
                      text_end_pos = editor.getTextLength()
                      counter = 0
                      found = editor.findText(0,0,text_end_pos, search_term)
                      while found is not None:
                          counter += 1
                          found = editor.findText(0,found[1],text_end_pos, search_term)
                      
                      editor.copyText(counter)
                      

                      would count how often def is in the current text and copy the result.

                      May I ask, what you exactly try to achieve, maybe a single python script could do the
                      job.

                      Cheers
                      Claudia

                      1 條回覆 最後回覆 回覆 引用 0
                      • Ed BernasconiE
                        Ed Bernasconi
                        最後由 編輯

                        Hello Claudia,
                        Yes, Macro Scheduler can read the Clipboard. What I’m trying to do is simply to have the Macro not run some loops more than necessary which, to my mind, is not very elegant. I can, of course, have it run a worst case number of times, 65 in the case on hand, when it would be better to have it run just the number of times it really needs.
                        I’ll try to find a workaround.

                        Thank you very much for your help… I appreciate it.
                        I’ll have another problem in a couple of days. I’ll let you know :)

                        Ed

                        1 條回覆 最後回覆 回覆 引用 0
                        • Ed BernasconiE
                          Ed Bernasconi
                          最後由 編輯

                          Hello Claudia,
                          Problem solved, developing your first (collapse all) suggestion.
                          The first line is the one that interests me when I do the search count on one file, the one that would read “Search “<img” (211 hits in 1 file)”. Easy to clean up so that only the “211” is left. Copy into Clipboard and read it into the Macro Scheduler editor. Works perfectly!

                          Thank you so much for having shown me the way!
                          Ed

                          Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
                          • Claudia FrankC
                            Claudia Frank @Ed Bernasconi
                            最後由 編輯

                            @Ed-Bernasconi

                            Your welcome - good to see you have a workaround.

                            Cheers
                            Claudia

                            1 條回覆 最後回覆 回覆 引用 0
                            • 第一個貼文
                              最後的貼文
                            The Community of users of the Notepad++ text editor.
                            Powered by NodeBB | Contributors