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
}
}