AutoHotkey
AutoHotkey copied to clipboard
Explorer Lib With Tabs In Windows 11
In the Explorer Lib, in order to retrieve the right tab/window in the Windows 11 Explorer, you need to check if the window title is the same as the title of the tab in addition to checking if it is the right hwnd:
Explorer_GetWindow(hwnd="")
{
WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
WinGetClass class, ahk_id %hwnd%
If (process!="explorer.exe")
Return
If (class ~= "(Cabinet|Explore)WClass")
{
WinGetTitle, currentWindowTitle, A
For window In ComObjCreate("Shell.Application").Windows
If (window.hwnd == hwnd And window.LocationName == currentWindowTitle)
Return window
}
Else If (class ~= "Progman|WorkerW")
Return "desktop" ; desktop found
}
The two thing I added to the code are WinGetTitle, currentWindowTitle, A
and And window.LocationName == currentWindowTitle