Toggle the Find Results Window in Notepad++ with a Hotkey

I write software and play with websites in my spare time, mostly using Notepad++.  One of the banes of my existence is that there is no keyboard shortcut for closing the Find Results pane / window that appears when I do one of the following:

  • Find All in All Opened Documents
  • Find All in Current Document
  • Find All (in multiple files)

There isn’t one built in, as discussed in this question on, as well as this one and this one. F7 opens the pane or window, but doesn’t close it. The second question link above suggests that Esc will close the pane or window, but this doesn’t work for me, at least in Notepad++ >= 6.

I got fed up with this and created a script for my own use, using AutoHotKey. The following script will convert F7 from an open-only shortcut to a toggle; it opens it if it isn’t already open, and closes it if it is.

Here is the script:

I hope this helps everyone else out there who loves Notepad++!

Note: I posted this originally on

Edited 1/14/2014 to fix a bug in detecting the undocked window







11 responses to “Toggle the Find Results Window in Notepad++ with a Hotkey”

  1. ss005 Avatar

    Thank You, ED COTTRELL.
    Thank you very much for sharing your script.
    Now annoying behavior of built in F7 of npp has gone… 🙂
    Thanks again.

    1. Ed Avatar

      Glad it helps!

  2. Tobias Avatar

    Hi Ed, I’ve been using your solution for quite some time now and really appreciate it as I’m very keyboard-oriented. Unfortunately it seems to have broken when updating from Notepad++ 6.9.* to 7.2.1. As I’m not very familiar with AHK – any chance you have already solved this?
    Many thanks in advance, Tobias

    1. Ed Cottrell Avatar

      I’m afraid not, sorry. I have started using Sublime Text much more often than Notepad++, so I haven’t really investigated this issue in 7.2.

      1. Tobias Avatar

        Thanks for you prompt feedback. A Windows reboot fixed the problem so it seems it is actually not broken in 7.2, it was just temporarily broken by the update process.

        1. Ed Avatar

          Ah, good to know. Thanks for replying!

  3. Jim Avatar

    Hi Ed,
    Thanks for sharing this very useful function. I added it to my lengthy Autohotkey script, and I’ll be using your function almost daily.

    FYI, There appear to be a couple bugs in your script:

    1) Any document with Notepad++ in the title will match the first “If”, due to these statements:
    SetTitleMatchMode 2.
    If WinActive(“Notepad++”)
    For example, a Word document named “Notepad++.docx” will match, if the Word document is open and the active window.

    2) If the main Notepad++ window is active, and the “Find result” pane is undocked, pressing F7 will not close the “Find result” pane. I’m guessing that was not intended, but perhaps it was.

    I wrote a fix for those bugs, and will post it separately.

    Thanks again for a very useful script!

  4. Jim Avatar

    ; Jim’s mod to Ed Cottrell’s AutoHotKey script for toggling the “Find Results” pane/window in Notepad++
    ; Release Date: 6/20/2017
    ; Released under the MIT License (
    ; Ed’s original script:

    ; Turn F7 into a toggle for the Notepad++ search results window; currently it shows it, but doesn’t hide it.
    ; The $ prevents this from firing itself
    ; SetTitleMatchMode, 1: A window’s title must start with the specified
    ; WinTitle to be a match.
    SetTitleMatchMode, 1
    ; If statement:
    ; Tests if the active Window’s executable is notepad++.exe,
    ; AND if the active window is either:
    ; a) the undocked “Find result” window, OR
    ; b) the main Notepad++ window
    ; This If statement ensures no attempt is made to close the “Find result” window
    ; when the active window is some other Notepad++ window, e.g., its Find or Open windows.
    If ( WinActive(“ahk_exe notepad++.exe”)
    and ( ( WinActive(“Find result”) and WinActive(“ahk_class #32770”))
    or WinActive(“ahk_class Notepad++”) ) )
    ; Close the undocked “Find results” window, if it exists
    If ( WinExist(“ahk_class #32770”) and WinExist(“Find result”) )
    WinClose, Find result ahk_class #32770
    ; If the docked “Find result” pane is open, close it
    ; Button1 is the class name for the title bar and close button of the results pane when docked
    ; In ControlGet, the WinTitle parameter is A, which is the active window.
    ; This avoids potential, but unlikely, problems from having multiple Notepad++
    ; windows open.
    ControlGet, OutputVar, Visible,, Button1, A
    if ErrorLevel = 0
    ; Test if Find Result pane is docked
    If OutputVar > 0
    ; Found it docked
    ; Get the size and coordinates of the title bar and button
    ControlGetPos, X, Y, Width, Height, Button1
    ; Set the coordinates of the close button
    X := Width – 9
    Y := 5
    ; Send a click
    ControlClick, Button1,,,,, NA x%X% y%Y%
    SendInput {F7}

  5. Jim Avatar

    I’m posting a bug-fix for the code I posted earlier.
    I think the bug is also in Ed’s posted code.

    a) Notepad++’s Find window (Ctrl+F) is open, but it is not the active window.
    b) Notepad++ is the active window
    c) The “Find results” pane is open and docked.

    F7 results in a click being sent via:
    ControlClick, Button1,,,,, NA x%X% y%Y%
    The click is intended to close the “Find results” pane.
    However, the click appears to occur somewhere in the Find window (e.g., it becomes active).
    The “Find results” pane is not closed.
    Apparently, the “Button1” parameter is matching on a control which starts with “Button1” in the Find window.

    Replace: ControlClick, Button1,,,,, NA x%X% y%Y%
    With: ControlClick, Button1, A,,,, NA x%X% y%Y%

    The parameter “A” indicates to use active window, which is the main Notepad++ window.

    1. Ed Cottrell Avatar

      Jim, thanks for posting this. I’ll have to take your word for it, as I don’t use Windows much anymore and don’t use AutoHotKey at all. Hopefully it will help other users, though!

  6. Jim Avatar

    I’m posting another bug-fix for the code I posted a year ago.
    I encountered this bug when using the code on a different workstation, with presumably more recent versions of Autohotfix, Notepad++, and Windows 10.
    The bug symptom is that the hotkey does not work.

    Replace: ControlGetPos, X, Y, Width, Height, Button1
    With: ControlGetPos, X, Y, Width, Height, Button1, , Caption

Leave a Reply

Your email address will not be published. Required fields are marked *