Skip to content

Instantly share code, notes, and snippets.

@Onurtag
Last active February 25, 2024 07:23
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Onurtag/166df8b88744c48e93a64b7c89652e0a to your computer and use it in GitHub Desktop.
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 ;Comment this line by adding a ; in front of # if you want the tray icon to be visible. Like ;#NoTrayIcon
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.
;Default hotkey is ^F (Ctrl+F). Replace each ^F with F3 if you want to use that hotkey instead.
;You can delete each block below if you don't want its features.
EnvGet, UserProfile, UserProfile
;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::
;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]
RunPath := StrSplit(RunPath, ": ")[2]
;If we are unable to find breadcrumb text, try again using the window title. This helps with detecting Recycle Bin & Home folders.
if (RunPath == "") {
WinGetTitle, windowTitle, A
RunPath := windowTitle
}
;Uncomment below for debugging
; MsgBox, % RunPath
isDirectPath := ":\"
IfNotInString, RunPath, %isDirectPath%
{
if (RunPath == MyThisPC || RunPath == MyHome) ;PC, This PC or Home
{
RunPath := ""
} else if (RunPath == MyRecycleBin) { ;Recycle Bin
RunPath = -s "\$RECYCLE.BIN "
} else {
;Try using the GetExplorerPath method (works on %userprofile%, OneDrive, Pictures, Music, Videos etc.)
myPath := GetActiveExplorerPath()
if (myPath && !InStr(myPath, "::{")) { ;skip ::{GUID} paths (Recycle Bin, This PC etc...)
RunPath = -p "%myPath%"
} else {
if (WinActive("ahk_class #32770")) {
;if the current window is a full file picker try this
if (FileExist(UserProfile . "\" . RunPath)) {
RunPath = -p "%UserProfile%\%RunPath%\"
} else {
RunPath = ""
}
} else {
RunPath = ""
}
}
}
} else {
RunPath = -p "%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
;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() {
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
}
}
@kamilmirza
Copy link

thank you so much this script
i'm using it with ^F and F3
win10 x64 1709

@taimursaeed
Copy link

Great work

@HydrangeaPurple
Copy link

;BLOCK 3 - EXPLORER WINDOW
RunPath := SubStr(RunPath, 5) ; win10 x64 20h2 Chinese Language

@kaiwizz
Copy link

kaiwizz commented Oct 12, 2022

Thanks so much for this.

@slim-python
Copy link

how to use it? any tuts?

@kaiwizz
Copy link

kaiwizz commented Nov 13, 2022

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

@Onurtag
Copy link
Author

Onurtag commented Nov 14, 2022

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
Copy link

kaiwizz commented Nov 24, 2022

@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
Copy link

kaiwizz commented Nov 24, 2022

@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
Copy link
Author

Onurtag commented Nov 24, 2022

@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
Copy link

kaiwizz commented Nov 24, 2022

@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
Copy link
Author

Onurtag commented Nov 24, 2022

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

@kaiwizz
Copy link

kaiwizz commented Nov 24, 2022

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

@kaiwizz
Copy link

kaiwizz commented Feb 13, 2023

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
Copy link
Author

Onurtag commented Feb 13, 2023

@kaiwizz I'll take a look tomorrow

@Onurtag
Copy link
Author

Onurtag commented Feb 15, 2023

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

@kaiwizz
Copy link

kaiwizz commented Oct 11, 2023

@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
Copy link
Author

Onurtag commented Oct 12, 2023

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

@Onurtag
Copy link
Author

Onurtag commented Oct 12, 2023

@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
Copy link

kaiwizz commented Oct 12, 2023

@Onurtag Microsoft Windows [Version 10.0.22621.2428].

@Onurtag
Copy link
Author

Onurtag commented Oct 12, 2023

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

@kaiwizz
Copy link

kaiwizz commented Oct 12, 2023

@Onurtag yes.

@Onurtag
Copy link
Author

Onurtag commented Oct 12, 2023

@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
Copy link

kaiwizz commented Oct 18, 2023

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

@Onurtag
Copy link
Author

Onurtag commented Oct 18, 2023

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

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