• Login
Community
  • Login

how do I clear find result window with keystrokes/shortcut

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 4 Posters 2.1k 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.
  • S
    Steve Aurelio
    last edited by Mar 21, 2019, 4:06 PM

    I use Find->Find All in Current Document frequently. When I want to clear the results window it is a right click-> Clear all. When using a mouse all day long it would be very helpful to have a command that I can map to a shortcut. I have searched but have not found anything in this area.

    1 Reply Last reply Reply Quote 0
    • C
      cipher-1024
      last edited by Mar 21, 2019, 4:29 PM

      If the focus is in the results pane, you can just cntrl-a, del. If you need to get the focus on the results pane hit F7. Sadly, since the F7 toggles between the results pane and the editor pane, an F7-select-all-then-delete macro would be a time bomb waiting to go off. Hopefully someone else has a better idea.

      A 1 Reply Last reply Mar 21, 2019, 5:35 PM Reply Quote 2
      • A
        Alan Kilborn @cipher-1024
        last edited by Mar 21, 2019, 5:35 PM

        @cipher-1024 said:

        an F7-select-all-then-delete macro would be a time bomb waiting to go off.

        Not to mention the fact that macros are really centric around editor operations, not rest-of-program operations. :)

        @Steve-Aurelio said:

        all day long

        Curious why you feel the need to “clear”? A new search “minimizes” previous searches (after which I just tend to ignore them).

        1 Reply Last reply Reply Quote 0
        • A
          Alan Kilborn
          last edited by Mar 21, 2019, 7:59 PM

          I was intrigued by this, mainly for the “can we do this?” potential rather than its usefulness to me… :)

          Thanks to Claudia’s (sniff, sniff) and Scott’s (sniff, sniff) earlier postings on the use of Python’s ctypes module, I was able to come up with this Pythonscript (that can be bound to a single keycombination) to do what the OP has asked for:

          import ctypes
          from ctypes.wintypes import BOOL, HWND, LPARAM
          
          # helpers for ctypes:
          WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
          FindWindow = ctypes.windll.user32.FindWindowW
          GetWindowText = ctypes.windll.user32.GetWindowTextW
          GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
          SendMessage = ctypes.windll.user32.SendMessageW
          EnumChildWindows = ctypes.windll.user32.EnumChildWindows
          GetClassName = ctypes.windll.user32.GetClassNameW
          curr_class = ctypes.create_unicode_buffer(256)
          
          # other helpers:
          WM_COMMAND = 0x111
          NPPM_INTERNAL_SCINTILLAFINFERCLEARALL = 0x400 + 27
          
          find_result_panel_hwnd = None
          
          def foreach_window(hwnd, lParam):
              cc = curr_class[:GetClassName(hwnd, curr_class, 256)]
              if cc == u'#32770':
                  length = GetWindowTextLength(hwnd)
                  if length > 0:
                      buff = ctypes.create_unicode_buffer(length + 1)
                      GetWindowText(hwnd, buff, length + 1)
                      if buff.value == u'Find result':
                          global find_result_panel_hwnd
                          find_result_panel_hwnd = hwnd
              return True
          EnumChildWindows(FindWindow(u'Notepad++', None), WNDENUMPROC(foreach_window), 0)
          
          if find_result_panel_hwnd != None: SendMessage(find_result_panel_hwnd, WM_COMMAND, NPPM_INTERNAL_SCINTILLAFINFERCLEARALL, 0)
          

          Not sure if the OP is inclined to use the Pythonscript plugin to achieve the goal, but that’s neither here nor there to me. :)

          M 1 Reply Last reply Mar 21, 2019, 8:17 PM Reply Quote 2
          • A
            Alan Kilborn
            last edited by Mar 21, 2019, 8:11 PM

            For the purists out there, stick a return False after the find_result_panel_hwnd = hwnd line and indented to that same level. The purists can also I’m sure find other problems or ways to improve. It works (for me) as above. :)

            1 Reply Last reply Reply Quote 1
            • M
              Meta Chuh moderator @Alan Kilborn
              last edited by Meta Chuh Mar 21, 2019, 8:18 PM Mar 21, 2019, 8:17 PM

              @Alan-Kilborn

              Thanks to Claudia’s (sniff, sniff) and Scott’s (sniff, sniff) earlier postings

              i have avoided to whine about their “temporal” leave lately, especially after a few of your reprehensions about this … and now you remind me again (sniff, sniff) 😉
              at least scott is still around, albeit not active. 👀

              reader’s note: for anyone that wants to try out the code from above, here’s the:
              Guide: How to install the PythonScript plugin on Notepad++ 7.6.3, 7.6.4 and above:

              A 1 Reply Last reply Mar 21, 2019, 8:21 PM Reply Quote 1
              • A
                Alan Kilborn @Meta Chuh
                last edited by Mar 21, 2019, 8:21 PM

                @Meta-Chuh

                The sniffling was mainly for your benefit as Claudia and Scott will never see it. :)

                Your guide is conspicuously missing how to set up PS with a portable N++ >= 7.6.3. Or was this discussed elsewhere?

                M 1 Reply Last reply Mar 21, 2019, 8:41 PM Reply Quote 1
                • M
                  Meta Chuh moderator @Alan Kilborn
                  last edited by Mar 21, 2019, 8:41 PM

                  @Alan-Kilborn

                  The sniffling was mainly for your benefit

                  i thought so, and my first thought was: how thoughtful of you :)

                  as Claudia and Scott will never see it. :)

                  hmmmmmh … sure about that ? what if someone else is claudia in disguise ? 😈🍏🐍

                  Your guide is conspicuously missing how to set up PS with a portable N++ >= 7.6.3. Or was this discussed elsewhere?

                  yes, e.g. here: https://notepad-plus-plus.org/community/topic/17256/guide-how-to-install-the-pythonscript-plugin-on-notepad-7-6-3-7-6-4-and-above/1
                  or here: https://notepad-plus-plus.org/community/topic/16942/pythonscript-any-ready-pyscript-to-replace-one-huge-set-of-regex-phrases-with-others/12

                  but never as a stand alone guide, because apparently portable users usually know how to install it.

                  if it get’s asked again, i, or anybody else, might make a new guide about that.

                  (ps: in other words: i’ve completely forgotten that, while writing the guide … but hushhhhhhhh, dont tell anyone 😉 )

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