Output to Clipboard of "Count" function in search panel

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


  • @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… :-)

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


  • @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. :-)

  • 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-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)

    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


  • 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 :)


  • 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-Bernasconi

    Your welcome - good to see you have a workaround.


Log in to reply