Skip to content

Instantly share code, notes, and snippets.

@Onurtag
Last active May 21, 2026 17:34
Show Gist options
  • Select an option

  • Save Onurtag/166df8b88744c48e93a64b7c89652e0a to your computer and use it in GitHub Desktop.

Select an option

Save Onurtag/166df8b88744c48e93a64b7c89652e0a to your computer and use it in GitHub Desktop.
ExploreEverything.ahk: An autohotkey (ahk v1) script that allows you to search the current explorer folder, your desktop and more using Everything
#SingleInstance Force
#NoTrayIcon ;If you want the tray icon to be visible; comment this line by adding a semicolon ; in front of the #. Example: ;#NoTrayIcon
; ALTERNATIVE METHOD: Try the built-in Everything option "hotkey_explorer_path_search"
; ^^^INFO: https://www.voidtools.com/forum/viewtopic.php?p=17390#p17390
EverythingPath := "C:\Program Files\Everything\Everything.exe" ;Set this to your everything.exe path. Keep the quotes.
;---Optional setup for special folders---
MyRecycleBin := "Recycle Bin" ;If your OS is not English, go to your explorer's "Recycle Bin" (๐Ÿšฎ) folder and change this to the title of that window. Keep the quotes.
MyThisPC := "This PC" ;If your OS is not English, go to your explorer's "This PC" (๐Ÿ’ป) folder and change this to the title of that window. Keep the quotes.
MyHome := "Home" ;(Windows 11) If your OS is not English, go to your explorer's "Home" (๐Ÿ ) folder and change this to the title of that window. Keep the quotes.
MyFullName := ""
try {
;Get full user name (for file picking dialog)
MyFullName := GetUserFullName()
} catch e {
MyFullName := ""
}
EnvGet, UserProfile, UserProfile
;Default hotkey is ^F (Ctrl+F). Replace each ^F with F3 if you want to use that hotkey instead.
;You may delete each block below if you don't need its features.
;BLOCK 1 - DESKTOPS
#If, WinActive("ahk_class WorkerW") or WinActive("ahk_class Progman")
^F::
RunPath = -p "%UserProfile%\Desktop\"
Run, %EverythingPath% %RunPath%
WinWait, ahk_exe everything.exe,, 2
if (!ErrorLevel) {
Sleep, 125
WinActivate, ahk_exe everything.exe
}
Return
;BLOCK 2 - TASKBARS
#If, WinActive("ahk_class Shell_TrayWnd") or WinActive("ahk_class Shell_SecondaryTrayWnd")
^F::
Run, %EverythingPath%
WinWait, ahk_exe everything.exe,, 2
if (!ErrorLevel) {
Sleep, 125
WinActivate, ahk_exe everything.exe
}
Return
;BLOCK 3 - EXPLORER WINDOWS and FILE PICKING DIALOGS (only for the full file picking dialog)
#If, WinActive("ahk_class CabinetWClass") or WinActive("ahk_class #32770")
^F::
;Try using the GetExplorerPath method (doesn't work on the file picker dialog)
;Doesn't work with Recycle Bin, This PC, Home... (probably more)
RunPath := GetActiveExplorerPath()
if (InStr(RunPath, "::{")) {
;If the function returns a GUID path, retry using the manual method below.
RunPath := ""
} else if (RunPath != "") {
;Finalize commandline
RunPath = -p "%RunPath%"
}
if (RunPath == "") {
;Function method failed OR this is a file picking dialog
;To find the correct control path use an inspector application (UIAViewer, System Informer, Winspector etc..)
;Find Breadcrumb Parent1 -> ToolbarWindow321
ControlGet, crumbHWND, Hwnd,, Breadcrumb Parent1, A
ControlGetText, RunPath, ToolbarWindow321, ahk_id %crumbHWND%
;Cleanup the string (Location: C:\Dir1\Dir2)
;Windows paths can't include the ":" character so we don't need to combine result[2]...result[last]
try {
RunPath := StrSplit(RunPath, ": ")[2]
}
if (RunPath == "") {
;If we are still unable to find breadcrumb text, try again using the window title. This can help us detect some special named folders.
WinGetTitle, windowTitle, A
RunPath := windowTitle
}
if (FileExist(RunPath)) { ;Check if its a regular path
;Finalize commandline
RunPath = -p "%RunPath%"
} else if (FileExist(UserProfile . "\" . RunPath)) { ;Check if its a user folder
RunPath = -p "%UserProfile%\%RunPath%\"
;Check special named paths
} else if (RegExMatch(RunPath, "^" . MyThisPC) || RegExMatch(RunPath, "^" . MyHome)) { ;This PC or Home
RunPath := ""
} else if (RegExMatch(RunPath, "^" . MyRecycleBin)) { ;Recycle Bin
RunPath = -s "\$RECYCLE.BIN "
} else if (MyFullName && RegExMatch(RunPath, "^" . MyFullName)) { ;UserProfile folder (using MyFullName)
RunPath = -p "%UserProfile%"
} else {
;Abort
RunPath = ""
}
}
;Uncomment below for debugging
; MsgBox, %EverythingPath% %RunPath%
Run, %EverythingPath% %RunPath%
WinWait, ahk_exe everything.exe,, 2
if (!ErrorLevel) {
Sleep, 125
WinActivate, ahk_exe everything.exe
}
Return
#If
;FUNCTIONS
GetUserFullName() {
username := A_UserName
; Connect to the WMI service
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!" . "\\.\root\cimv2")
; Query the Win32_UserAccount class for the current username
colItems := objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name='" . username . "'")
; Loop through the results to get the FullName
for objItem in colItems {
return objItem.FullName
}
}
;GetActiveExplorerPath by ntepa https://www.autohotkey.com/boards/viewtopic.php?p=507423#p507423
;Works correctly in all situations except for special ::{GUID} folders (Recycle Bin, Home, Gallery)
GetActiveExplorerPath() {
try {
hwnd := WinActive("ahk_class CabinetWClass")
activeTab := 0
try ControlGet, activeTab, Hwnd,, % "ShellTabWindowClass1", % "ahk_id" hwnd
for w in ComObjCreate("Shell.Application").Windows {
if (w.hwnd != hwnd)
continue
if activeTab {
static IID_IShellBrowser := "{000214E2-0000-0000-C000-000000000046}"
shellBrowser := ComObjQuery(w, IID_IShellBrowser, IID_IShellBrowser)
DllCall(NumGet(numGet(shellBrowser+0)+3*A_PtrSize), "Ptr", shellBrowser, "UInt*", thisTab)
if (thisTab != activeTab)
continue
ObjRelease(shellBrowser)
}
return w.Document.Folder.Self.Path
}
} catch e {
;MsgBox,, ExploreEverything Error, % e.Message
;Return blank on failure
return ""
}
}
@Onurtag

Onurtag commented Nov 14, 2022

Copy link
Copy Markdown
Author

how to use it? any tuts? @slim-python

Sorry for the late reply. Install Autohotkey , download this file (ExploreEverything.ahk) and run it. Now you can use the hotkey to start the Voidtools Everything application on the current folder. Default hotkey is Ctrl+F (^F in autohotkey language) and you can replace those ^F 's with F3 's if you want.

Hello, I think this is not working after the latest update of windows 11. @kaiwizz

Yeah, it wasn't working on the new tabbed file browser. I updated the script. Let me know if it still doesn't work.

@kaiwizz

kaiwizz commented Nov 24, 2022

Copy link
Copy Markdown

@Onurtag
Thanks a lot. it is working now. Somehow it was not working when I just copied and pasted. I needed to delete the First Blank line and now it works.

@kaiwizz

kaiwizz commented Nov 24, 2022

Copy link
Copy Markdown

@Onurtag

offtopic. Can you do something similar but instead of opening everything, you launch the new windows terminal in that location?
I know that to launch the terminal at a specific location, let's say the python folder inside c drive, you need to run wt -d c:\python. But I am unable to get it to work.

You might find it handy if you use the terminal app in Windows.

@Onurtag

Onurtag commented Nov 24, 2022

Copy link
Copy Markdown
Author

@kaiwizz I usually do a shift+right click -> open in terminal on any folder for that functionality. It works for me.

If you want to edit this script for yourself you can try the following:

  1. change the hotkeys ^F ctrl F to something else
  2. set EverythingPath to "wt"
  3. change all RunPath = -d ... lines to RunPath = -p ...

@kaiwizz

kaiwizz commented Nov 24, 2022

Copy link
Copy Markdown

@Onurtag
Hey, thanks for your guidance. It is mostly acting as I want it to work. But getting the focus on the opened terminal is not working properly. Sometimes it does, and sometimes it does not. Here's the snippet for the desktop block. I don't know what I am doing wrong.

;BLOCK 1 - DESKTOPS
#If, WinActive("ahk_class WorkerW") or WinActive("ahk_class Progman")
#enter::
    RunPath = -d "%UserProfile%\Desktop"
    Run, %WindowsTerminal% %RunPath%
    WinWait, ahk_exe wt.exe,, 2
    if (!ErrorLevel){
        Sleep, 125
        WinActivate, ahk_exe wt.exe
    }
Return

@Onurtag

Onurtag commented Nov 24, 2022

Copy link
Copy Markdown
Author

@kaiwizz No problem. Thats because the opened window uses WindowsTerminal.exe , just replace those two wt.exe 's and it should work.

@kaiwizz

kaiwizz commented Nov 24, 2022

Copy link
Copy Markdown

@Onurtag Thanks a lot. Now it works like a charm!

@kaiwizz

kaiwizz commented Feb 13, 2023

Copy link
Copy Markdown

Hello @Onurtag ,

I am having issues with your script. If I have a single tab in explorer, then your script works, but if I have multiple tabs opened and try to search in any of those tabs, it breaks.

I am using windows 11, Version 10.0.22621 Build 22621.

@Onurtag

Onurtag commented Feb 13, 2023

Copy link
Copy Markdown
Author

@kaiwizz I'll take a look tomorrow

@Onurtag

Onurtag commented Feb 15, 2023

Copy link
Copy Markdown
Author

@kaiwizz I updated the script with the fix for the tabbed explorer. It should work much better now.
Thanks for the bug report.

@kaiwizz

kaiwizz commented Oct 11, 2023

Copy link
Copy Markdown

@Onurtag , The last Windows update messed up the script, it is not working for tabbed windows anymore for me. It is actually not working in single folders if I am in some folder other than the windows folders like Documents or Downloads.

@Onurtag

Onurtag commented Oct 12, 2023

Copy link
Copy Markdown
Author

I'm guessing thats probably the new WinUI 3 explorer. I will take a look at it soon.

@Onurtag

Onurtag commented Oct 12, 2023

Copy link
Copy Markdown
Author

@kaiwizz Can you tell me your full windows version? It should be at the top when you open a cmd window.
It should be something like Microsoft Windows [Version 10.0.22621.2428] .
I just tested on the version above and everything worked fine (two windows both with multiple tabs). I am asking for the version you are using so I can decide whether I should update to a pre-release insider version.

@kaiwizz

kaiwizz commented Oct 12, 2023

Copy link
Copy Markdown

@Onurtag Microsoft Windows [Version 10.0.22621.2428].

@Onurtag

Onurtag commented Oct 12, 2023

Copy link
Copy Markdown
Author

@kaiwizz Thank you. It looks like this right?
image

@kaiwizz

kaiwizz commented Oct 12, 2023

Copy link
Copy Markdown

@Onurtag yes.

@Onurtag

Onurtag commented Oct 12, 2023

Copy link
Copy Markdown
Author

@kaiwizz I pushed an update but I'm not sure if this will fix your problem. Download the new version, test it and let me know if you still have problems.

@kaiwizz

kaiwizz commented Oct 18, 2023

Copy link
Copy Markdown

@Onurtag Tested your new script today. So Far I have not faced any issues. Thanks a lot.

@Onurtag

Onurtag commented Oct 18, 2023

Copy link
Copy Markdown
Author

@kaiwizz Great! Thanks for the bug report and the confirmation.

@kaiwizz

kaiwizz commented Sep 11, 2024

Copy link
Copy Markdown

@Onurtag , the latest Windows update broke the script again.
I think the issue is, after the current Windows update, "- File Explorer" is added to the path as, "C:\Users\testUser\Documents\folder\subfolder - File Explorer\"

@Onurtag

Onurtag commented Sep 12, 2024

Copy link
Copy Markdown
Author

@kaiwizz Thanks for the detailed report! I am now updating my win11 setup to the latest release preview.
It is easy to just strip the "- File Explorer" from the string but that might not work on any other language so I need to see it for myself.

@Onurtag

Onurtag commented Sep 14, 2024

Copy link
Copy Markdown
Author

@kaiwizz I have updated the script with some changes, let me know how it works for you now.

I tested the script on 3 different Windows 11 versions but I was unable to replicate the error that adds the - File Explorer string to the folder path. This might be caused by the A/B testing system used by Microsoft.
If the script is still not working I might need some extra info like your current windows version (its visible on cmd) and whether the script is broken on every folder or just a few folders like pictures, videos etc.

@kaiwizz

kaiwizz commented Sep 17, 2024

Copy link
Copy Markdown

@Onurtag
Thanks for the fixes, it's working for me now.

From cmd, Microsoft Windows [Version 10.0.22631.4169]

@Onurtag

Onurtag commented Sep 17, 2024

Copy link
Copy Markdown
Author

@kaiwizz Great to hear!

@Onurtag

Onurtag commented Mar 22, 2025

Copy link
Copy Markdown
Author

For information:
I just found this built-in Everything option called hotkey_explorer_path_search. If you set that option in Everything.ini to 1, the global everything hotkey will open on the current explorer folder by default (only works on regular explorer windows)

INFO: https://www.voidtools.com/forum/viewtopic.php?p=17390#p17390

EDIT: This hotkey is supposed to only work on explorer windows and nothing else.

@kaiwizz

kaiwizz commented Mar 27, 2025

Copy link
Copy Markdown

@Onurtag I did try to follow the instructions in the link you provided

In Everything, type in the following search and press ENTER:
/hotkey_explorer_path_search=1

But nothing seemed to happen. I went to the keyboard shortcuts to find the hotkey that is supposed to be set, but I did not see anything like that.

@Onurtag

Onurtag commented Mar 27, 2025

Copy link
Copy Markdown
Author

@kaiwizz When I set the config and restarted Everything, the "New window hotkey" in everything options opened the active explorer folder. On windows 10.
Although everything is only updated on the 1.5 alpha version right now and the single dev might not have had the time to update this feature for the newest windows 11 explorer.exe.
It only works on explorer windows.

@NightMean

Copy link
Copy Markdown

As this script is only for Autohotkey v1 and I currently need to use v2, I've asked AI to modify it to be compatible with v2. To my surprise it worked on the first try. There might be bugs that I do not know about but from simple testing it worked as expected.

#Requires AutoHotkey v2.0
#SingleInstance Force
#NoTrayIcon                     ;If you want the tray icon to be visible; comment this line by adding a semicolon ; in front of the #. Example: ;#NoTrayIcon

; ALTERNATIVE METHOD: Try the built-in Everything option "hotkey_explorer_path_search"
; ^^^INFO: https://www.voidtools.com/forum/viewtopic.php?p=17390#p17390

EverythingPath := "C:\Program Files\Everything\Everything.exe"    ;Set this to your everything.exe path. Keep the quotes.

;---Optional setup for special folders---
MyRecycleBin := "Recycle Bin"   ;If your OS is not English, go to your explorer's "Recycle Bin" (๐Ÿšฎ) folder and change this to the title of that window. Keep the quotes.
MyThisPC := "This PC"           ;If your OS is not English, go to your explorer's "This PC" (๐Ÿ’ป) folder and change this to the title of that window. Keep the quotes.
MyHome := "Home"                ;(Windows 11) If your OS is not English, go to your explorer's "Home" (๐Ÿ ) folder and change this to the title of that window. Keep the quotes.

MyFullName := ""
try {
    ;Get full user name (for file picking dialog)
    MyFullName := GetUserFullName()
}

UserProfile := EnvGet("UserProfile")

;Default hotkey is ^f (Ctrl+F). Replace each ^f with F3 if you want to use that hotkey instead.
;You may delete each block below if you don't need its features.

;BLOCK 1 - DESKTOPS
#HotIf WinActive("ahk_class WorkerW") or WinActive("ahk_class Progman")
^f:: {
    RunPath := '-p "' UserProfile '\Desktop\"'
    Run(EverythingPath " " RunPath)
    if WinWait("ahk_exe everything.exe", , 2) {
        Sleep(125)
        WinActivate("ahk_exe everything.exe")
    }
}


;BLOCK 2 - TASKBARS
#HotIf WinActive("ahk_class Shell_TrayWnd") or WinActive("ahk_class Shell_SecondaryTrayWnd")
^f:: {
    Run(EverythingPath)
    if WinWait("ahk_exe everything.exe", , 2) {
        Sleep(125)
        WinActivate("ahk_exe everything.exe")
    }
}


;BLOCK 3 - EXPLORER WINDOWS and FILE PICKING DIALOGS (only for the full file picking dialog)
#HotIf WinActive("ahk_class CabinetWClass") or WinActive("ahk_class #32770")
^f:: {
    ;Try using the GetExplorerPath method (doesn't work on the file picker dialog)
    ;Doesn't work with Recycle Bin, This PC, Home... (probably more)
    RunPath := GetActiveExplorerPath()
    
    if InStr(RunPath, "::{") {
        ;If the function returns a GUID path, retry using the manual method below.
        RunPath := ""
    } else if (RunPath != "") {
        ;Finalize commandline
        RunPath := '-p "' RunPath '"'
    }

    if (RunPath == "") {
        ;Function method failed OR this is a file picking dialog

        ;To find the correct control path use an inspector application (UIAViewer, System Informer, Winspector etc..)
        ;Find Breadcrumb Parent1 -> ToolbarWindow321
        try {
            crumbHWND := ControlGetHwnd("Breadcrumb Parent1", "A")
            RunPath := ControlGetText("ToolbarWindow321", "ahk_id " crumbHWND)
            
            ;Cleanup the string (Location: C:\Dir1\Dir2)
            ;Windows paths can't include the ":" character so we don't need to combine result[2]...result[last]
            parts := StrSplit(RunPath, ": ")
            if parts.Length >= 2 {
                RunPath := parts[2]
            } else {
                RunPath := ""
            }
        } catch {
            RunPath := ""
        }
        
        if (RunPath == "") {
            ;If we are still unable to find breadcrumb text, try again using the window title. This can help us detect some special named folders.
            try RunPath := WinGetTitle("A")
        }
        
        if FileExist(RunPath) { ;Check if its a regular path
            ;Finalize commandline
            RunPath := '-p "' RunPath '"'
        } else if FileExist(UserProfile "\" RunPath) { ;Check if its a user folder
            RunPath := '-p "' UserProfile '\' RunPath '\"'

        ;Check special named paths
        } else if (RegExMatch(RunPath, "^" MyThisPC) || RegExMatch(RunPath, "^" MyHome)) { ;This PC or Home 
            RunPath := ""
        } else if RegExMatch(RunPath, "^" MyRecycleBin) { ;Recycle Bin
            RunPath := '-s "\$RECYCLE.BIN "'
        } else if (MyFullName != "" && RegExMatch(RunPath, "^" MyFullName)) { ;UserProfile folder (using MyFullName)
            RunPath := '-p "' UserProfile '"'
        } else {
            ;Abort
            RunPath := ""
        }
    }

    ;Uncomment below for debugging
    ;MsgBox(EverythingPath " " RunPath)
    Run(EverythingPath " " RunPath)
    if WinWait("ahk_exe everything.exe", , 2) {
        Sleep(125)
        WinActivate("ahk_exe everything.exe")
    }
}
#HotIf

;FUNCTIONS
GetUserFullName() {
    username := A_UserName
    try {
        ; Connect to the WMI service
        objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        ; Query the Win32_UserAccount class for the current username
        colItems := objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name='" username "'")
        ; Loop through the results to get the FullName
        for objItem in colItems {
            return objItem.FullName
        }
    }
    return ""
}

;GetActiveExplorerPath by ntepa (Updated for v2)
;Works correctly in all situations except for special ::{GUID} folders (Recycle Bin, Home, Gallery)
GetActiveExplorerPath() {
    try {
        hwnd := WinActive("ahk_class CabinetWClass")
        if !hwnd
            return ""
            
        activeTab := 0
        try activeTab := ControlGetHwnd("ShellTabWindowClass1", "ahk_id " hwnd)
        
        for w in ComObject("Shell.Application").Windows {
            if (w.hwnd != hwnd)
                continue
            if activeTab {
                static IID_IShellBrowser := "{000214E2-0000-0000-C000-000000000046}"
                shellBrowser := ComObjQuery(w, IID_IShellBrowser, IID_IShellBrowser)
                ComCall(3, shellBrowser, "ptr*", &thisTab := 0)
                if (thisTab != activeTab)
                    continue
            }
            return w.Document.Folder.Self.Path
        }
    }
    return ""
}

@Onurtag

Onurtag commented Mar 14, 2026

Copy link
Copy Markdown
Author

Looks good to me. If your company etc. is forcing ahk 2.0 this should work as well.

@eladkarako

Copy link
Copy Markdown

this is great script, thanks,
I've just used the window.Document.Folder.Self.Path along with small fixes,
and AutoHotKey version 2.0 syntax.

https://gist.github.com/eladkarako/56bc00236b9ee90001bf3ad2e3f3a16a#file-bind_f3_in_explorer_to_launch_everything_search_program_in_a_directory-ahk

(I also forked their documentation to https://eladkarako.github.io/docs_autohotkey_v2/docs/
because the cloudflare bot detection was too annoying)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment