However, this function only returns the selected items or folder of the first tab. Is it possible to make this work with other tabs?
Code: Select all
#p::MsgBox Explorer_GetSelection()
Explorer_GetSelection() {
winClass := WinGetClass(hwnd := WinExist("A"))
if !(winClass ~= "(Cabinet|Explore)WClass")
Return
for window in ComObject("Shell.Application").Windows
if (window.hwnd = hwnd) && (oShellFolderView := window.Document)
break
result := ""
for item in oShellFolderView.SelectedItems
result .= (result = "" ? "" : "`n") . item.path
Return result || oShellFolderView.Folder.Self.Path
}