• Login
Community
  • Login

Setting to close Find window after initiating search?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
10 Posts 3 Posters 908 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.
  • V
    Vinnie M
    last edited by Aug 11, 2020, 6:20 PM

    When I want to search, I press CTRL+F and enter some text then click the Find Next button to begin the search. The search dialog stays open. Is there any setting to close that window when the search begins. I usually just use F3 after the initial search to find additional occurrences.

    I realize there are other posts here for people who want to keep it open while searching, but I was just wondering if by chance there was an option to control this behavior.

    A 1 Reply Last reply Aug 11, 2020, 7:55 PM Reply Quote 0
    • A
      Alan Kilborn @Vinnie M
      last edited by Aug 11, 2020, 7:55 PM

      @Vinnie-M

      Probably the quickest way is to press Esc

      V 1 Reply Last reply Aug 12, 2020, 4:28 AM Reply Quote 3
      • V
        Vinnie M @Alan Kilborn
        last edited by Aug 12, 2020, 4:28 AM

        Ok, thanks. I was hoping for an option to close it after the initial Find Next button was clicked.

        A 1 Reply Last reply Aug 12, 2020, 11:37 AM Reply Quote 0
        • A
          Alan Kilborn @Vinnie M
          last edited by Aug 12, 2020, 11:37 AM

          @Vinnie-M

          Probably the desire for this is that the Find window takes up a huge amount of space?

          1 Reply Last reply Reply Quote 0
          • V
            Vinnie M
            last edited by Aug 12, 2020, 3:18 PM

            I just don’t need it at that point since I always do F3 after the initial entry of the search text. For me it’s just an unnecessary extra keystroke to remove it after starting the search.

            A 1 Reply Last reply Aug 12, 2020, 3:22 PM Reply Quote 0
            • A
              Alan Kilborn @Vinnie M
              last edited by Aug 12, 2020, 3:22 PM

              @Vinnie-M

              If your search term is the word at the caret or some small bit of text that you could select first, you can avoid the _Find window entirely by executing Select and Find Next, which by default is Ctrl+F3. Just a thought.

              1 Reply Last reply Reply Quote 3
              • V
                Vinnie M
                last edited by Aug 12, 2020, 6:28 PM

                That’s neat – Although it’s not always the case for my search term, I might be able to get used to that in those cases.

                1 Reply Last reply Reply Quote 2
                • S
                  SanderBouwhuis
                  last edited by SanderBouwhuis Nov 21, 2023, 10:28 AM Nov 21, 2023, 10:16 AM

                  I too am really annoyed by this. I use the keyboard when using Notepad because it is a text editor. Everytime I do a search I get a popup window which doesn’t automatically close after I press the ENTER/RETURN key.
                  This should be very easy to implement right? A simple setting which auto closes the popup window which is obscuring the text you are editing.
                  I’m aware I can press the ESC key to close the window, but it happening automatically would greatly improve the fluidity of using Notepad.

                  A 1 Reply Last reply Nov 21, 2023, 12:05 PM Reply Quote 1
                  • A
                    Alan Kilborn @SanderBouwhuis
                    last edited by Alan Kilborn Nov 21, 2023, 12:33 PM Nov 21, 2023, 12:05 PM

                    @SanderBouwhuis

                    The large Find window IS annoying on a single monitor setup (presume that is what yours is). On multiple monitors, it isn’t so bad, you can have Notepad++ maximized on one monitor and put the find window on the/an adjacent monitor.

                    Have you tried the “reduced size” Find window? It looks like this:

                    26c8d1e0-bb0e-4827-a1cd-209d5330a65b-image.png

                    and the size is toggled by the button I’ve highlighted in yellow; same relative location for the button in the larger version of the window, but it has a ^ caption in that case.


                    Another interesting idea would be if the Find window would go “roving” after each match is found…if it needs to. What this means is, if the text of the match found appears under the Find window, the window should reposition itself somewhere else, allowing you to see your matched text.

                    1 Reply Last reply Reply Quote 1
                    • A
                      Alan Kilborn
                      last edited by Nov 21, 2023, 7:20 PM

                      The desired behavior can be scripted if one wants to use a plugin (PythonScript) to achieve the goal.

                      I call the script FindNextClosesFindWindow.py and here is its listing:

                      # -*- coding: utf-8 -*-
                      from __future__ import print_function
                      
                      # see https://community.notepad-plus-plus.org/topic/19844/setting-to-close-find-window-after-initiating-search
                      
                      from Npp import *
                      import platform
                      from ctypes import (WinDLL, WINFUNCTYPE)
                      from ctypes.wintypes import (HWND, UINT, INT, WPARAM, LPARAM)
                      
                      #-------------------------------------------------------------------------------
                      
                      user32 = WinDLL('user32')
                      
                      GWL_WNDPROC = -4  # used to set a new address for the window procedure
                      
                      LRESULT = LPARAM
                      
                      WndProcType = WINFUNCTYPE(
                          LRESULT,                    # return type
                          HWND, UINT, WPARAM, LPARAM  # function arguments
                          )
                      
                      running_32bit = platform.architecture()[0] == '32bit'
                      
                      SetWindowLong = user32.SetWindowLongW if running_32bit else user32.SetWindowLongPtrW
                      SetWindowLong.restype = WndProcType
                      SetWindowLong.argtypes = [ HWND, INT, WndProcType ]
                      
                      SendMessageW = user32.SendMessageW
                      SendMessageW.restype = LRESULT
                      SendMessageW.argtypes = [ HWND, UINT, WPARAM, LPARAM ]
                      
                      WM_COMMAND = 0x111
                      WM_CLOSE = 0x10
                      
                      IDOK = 1  # 'Find Next' button in Find dialog
                      # for the following see https://github.com/notepad-plus-plus/notepad-plus-plus/blob/3c9d58176b0fd890d26e96d0208d2d981f1544e4/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h#L1
                      IDC_FINDNEXT = 1723  # 'Find down-arrow' button in Find dialog
                      IDC_FINDPREV = 1721  # 'Find up-arrow' button in Find dialog
                      
                      #-------------------------------------------------------------------------------
                      
                      class FNCFW(object):
                      
                          def __init__(self):
                              for try_count in (1, 2):
                                  if try_count == 2: notepad.menuCommand(MENUCOMMAND.SEARCH_FIND)
                                  for find_window_tab_caption in [ u'Find', u'Replace', u'Find in Files', u'Find in Projects', u'Mark' ]:
                                      self.find_window_hwnd = user32.FindWindowExW(None, None, u'#32770', find_window_tab_caption)
                                      if self.find_window_hwnd:
                                          self.new_find_wnd_proc_hook_for_SetWindowLong = WndProcType(self.new_find_wnd_proc_hook)
                                          self.orig_find_wnd_proc = SetWindowLong(self.find_window_hwnd, GWL_WNDPROC, self.new_find_wnd_proc_hook_for_SetWindowLong)
                                          if try_count == 2: self.close_find_window()
                                          return
                      
                          def new_find_wnd_proc_hook(self, hwnd, msg, wParam, lParam):
                              orig_wnd_proc_ret_val = self.orig_find_wnd_proc(hwnd, msg, wParam, lParam)
                              if msg == WM_COMMAND and wParam in [ IDC_FINDNEXT, IDC_FINDPREV, IDOK ]: self.close_find_window()
                              return orig_wnd_proc_ret_val
                      
                          def close_find_window(self): SendMessageW(self.find_window_hwnd, WM_CLOSE, 0, 0)
                      
                      #-------------------------------------------------------------------------------
                      
                      if __name__ == '__main__':
                          try:
                              fncfw
                          except NameError:
                              fncfw = FNCFW()
                      

                      It can be set up in startup.py to run automatically when Notepad++ starts via these two lines:

                      import FindNextClosesFindWindow
                      fncfw = FindNextClosesFindWindow.FNCFW()
                      
                      1 Reply Last reply Reply Quote 3
                      • A Alan Kilborn referenced this topic on Nov 21, 2023, 7:20 PM
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors