Opening File Explorer TAB Instead of New Window #2680
-
I love Flow Launcher, but one of the things I wish it would do is upon opening a window in the file explorer that it could open a tab instead. On windows 11, there was an amazing upgrade to have tabs on file explorer windows instead of opening multiple windows which was a game changer. Ultimately, I would just love if Flow Launcher could have new inputs for File Explorer be opened in a tab instead of a window or make the preference available for Windows 11 users. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
So this is the ahk file I've mentioned in Discord. It's based on several scripts I've seen on ahk official forum. You need to set it as the default file explorer in Flow Launcher. A bit buggy and slow but most of the time it works. Usage: Code: #Requires AutoHotkey v2
SetWinDelay 10 ; no delay after window func
if !WinExist("ahk_class CabinetWClass")
{
if A_Args[1] = "-d"
ShellExecute(A_Args[2])
else if A_Args[1] = "-f"
ShellExecute("/select," A_Args[2])
return
}
hwnd := OpenNewExplorerTab()
shell := ComObject("Shell.Application")
w := GetActiveExplorerTab(hwnd, shell)
if A_Args[1] = "-d"
w.Navigate("file:///" A_Args[2])
else if A_Args[1] = "-f"
{
NaviAndSelectItem(A_Args[2], w, shell)
}
OpenNewExplorerTab()
{
create_new_tab := false
if WinExist("ahk_class CabinetWClass")
{
WinActivate
;WinWaitActive "ahk_class CabinetWClass"
create_new_tab := true
}
else
{
return
}
if create_new_tab
{
Send "^t"
Sleep 150
}
return WinGetID("A")
}
GetActiveExplorerTab(hwnd, shell)
{
activeTab := 0
try activeTab := ControlGetHwnd("ShellTabWindowClass1", hwnd) ; File Explorer (Windows 11)
catch
return ; Error: No active tab
for w in shell.Windows {
if w.hwnd != hwnd
continue
if activeTab { ; The window has tabs, so make sure this is the right one.
static IID_IShellBrowser := "{000214E2-0000-0000-C000-000000000046}"
shellBrowser := ComObjQuery(w, IID_IShellBrowser, IID_IShellBrowser)
ObjAddRef(shellBrowser.ptr)
ComCall(3, shellBrowser, "uint*", &thisTab:=0)
if thisTab != activeTab
{
continue
}
}
return w
}
return ; Error
}
NaviAndSelectItem(itemPath, window, shell) {
SplitPath(itemPath, &filename, &dir)
w.Navigate("file:///" dir)
Sleep 100
ShellFolderView := window.Document
; Folder := ShellFolderView.Folder
; ItemFolder := shell.NameSpace(dir)
; Item := ItemFolder.ParseName(filename)
; ShellFolderView.SelectItem(Item, 0x1D)
ShellFolderView.SelectItem(itemPath, 0x1D)
}
ShellExecute(strArgs:="", nShowCmd:=1) {
; MsgBox strArgs
;http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
Return DllCall("shell32\ShellExecuteW"
, "uint", 0
, "uint", 0
, "str", "explorer.exe"
, "str", strArgs ; arguments
, "str", "" ; lpfile
, "int", nShowCmd ; specifies how an application is to be displayed when it is opened
, "uint" )
} |
Beta Was this translation helpful? Give feedback.
So this is the ahk file I've mentioned in Discord. It's based on several scripts I've seen on ahk official forum. You need to set it as the default file explorer in Flow Launcher. A bit buggy and slow but most of the time it works.
Usage:
what_ever_you_like.ahk {-d dir_name|-f file_name}
Code: