Loop OpenFolderNewTab for Win11

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fiendhunter
Posts: 140
Joined: 24 Jul 2019, 15:27

Loop OpenFolderNewTab for Win11

07 Mar 2023, 02:35

I have 4 folders shortcuts in C:\StartMenuNow folder. I want to open all in 4 tabs.
This code is working well. but "Send, {F4}^a%outTarget%{Enter}" this line makes me unpleasant. Do we have a function for "open folder %outTarget% in new tab" at Windows11?

Code: Select all

sleep 1000
SendMode Input
runwait, explorer.exe
sleep 100
Loop, Files, C:\StartMenuNow\*.lnk, F
{
   FileGetShortcut, % A_LoopFilePath, outTarget
   if !InStr(FileExist(outTarget), "D")
      continue
	sleep 250
	Path := GetActiveExplorerPath()
	if ( path = outTargetLast )
	{
	send ^t
	sleep 10
	}
    Sleep 10
    Send, {F4}^a%outTarget%{Enter}
    outTargetLast := outTarget
    Sleep 10
}
Sleep 200
ExitApp
return

GetActiveExplorerPath() { ; for win11 newtab, by user "ntepa", in https://www.autohotkey.com/boards/viewtopic.php?t=69925
    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
    }
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kaka2 and 141 guests