AutoHotkey icon indicating copy to clipboard operation
AutoHotkey copied to clipboard

Explorer Lib With Tabs In Windows 11

Open King-of-Kings-980 opened this issue 11 months ago • 0 comments

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

King-of-Kings-980 avatar Mar 12 '24 00:03 King-of-Kings-980