The only thing I'm missing is a way to activate that tab.
With WinActivate, the File Explorer is activated, showing its current tab, not the one returned by the loop.
Do you know how to activate the returned tab?
Code: Select all
getFileExplorerTab(path) {
hwnd := WinExist("A")
activeTab := 0
try activeTab := ControlGetHwnd("ShellTabWindowClass1", hwnd) ; File Explorer (Windows 11)
for w in ComObject("Shell.Application").Windows
{
if (w.LocationURL == path) {
return w
}
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)
ComCall(3, shellBrowser, "uint*", &thisTab:=0)
if thisTab != activeTab
continue
}
}
msgbox('end')
}
tab := getFileExplorerTab('file:///C:/Users/Ivo/Downloads')
if(tab)
{
msgbox(tab.LocationURL)
WinActivate(tab)
}
else
{
msgbox('tab is null')
}