I used this script for over a year and it worked amazing on Windows 10, but after moving to Windows 11 I have a problem with it, because it creates a New Text Document.txt only in the first tab of the currently opened explorer window, ignoring the tab I selected. I found this topic and it seems just like thing I need, but I have absolutely no idea how to incorporate GetActiveExplorerTab function in the existing script:
Code: Select all
#IfWinActive, ahk_class CabinetWClass
^+M::
vNameNoExt := "New Text Document"
vDotExt := ".txt"
vPath := ""
WinGet, hWnd, ID, A
for oWin in ComObjCreate("Shell.Application").Windows {
if (oWin.HWND = hWnd) {
vDir := oWin.Document.Folder.Self.Path
Loop {
vSfx := (A_Index=1) ? "" : " (" A_Index ")"
vName := vNameNoExt vSfx vDotExt
vPath := vDir "\" vName
if !FileExist(vPath)
break
}
FileAppend,, % vPath, UTF-8-RAW
break
}
}
oWin.Refresh()
for Item in oWin.Document.Folder.Items
if (Item.Path = vPath)
oWin.Document.SelectItem(Item, 3|4|8)
oWin := ""
return