AutoHotkey: Show the active path in the title bar (extended)
Jump to navigation
Jump to search
Based on AutoHotkey: Show the active path in the title bar (by SanskritFritz).
This version keeps important information from the original window title.
To get more space it can shorten the program name from "Total Commander" to "TC".
#SingleInstance, Force
#Persistent
boAppendToOrgTitle := 1 ; 1 = keep RunAs-user and TC version in title
boShortenTcName := 0 ; 1 = replace "Total Commander" with "TC"
sTcTitleName1 := "Total Commander"
sTcTitleName2 := "TC"
sTcTitleName := sTcTitleName1
SetTimer TaskSched_PathInTitle, 100
Return
TaskSched_PathInTitle:
if WinActive( "ahk_class TTOTAL_CMD" )
{
ControlGetText, sPath, TMyPanel3
If (sPath = "")
ControlGetText, sPath, TMyPanel2
sPath := SubStr(sPath, 1, StrLen(sPath) - 1)
WinGetTitle, sWinTitle1
sWinTitle := sWinTitle1
; *** title is reset after minimizing - find out current state
if (iTitlePos := InStr(sWinTitle, sTcTitleName1 . " "))
sTcTitleName := sTcTitleName1
else
if (iTitlePos := InStr(sWinTitle, sTcTitleName2 . " "))
sTcTitleName := sTcTitleName2
; "user - Total Commander... - regname or path"
; *** shorten original program name
if (boShortenTcName)
{
if (iTitlePos := InStr(sWinTitle, sTcTitleName . " ")) ; "Total Commander " / "TC "
{
sWinTitle := SubStr(sWinTitle, 1, iTitlePos - 1) . sTcTitleName2 . SubStr(sWinTitle, iTitlePos + StrLen(sTcTitleName))
sTcTitleName := sTcTitleName2
}
}
; *** keep original title part
if (boAppendToOrgTitle)
{
if (iWinTitleEnd := InStr(sWinTitle, sTcTitleName . " ", true)) ; "Total Commander " / "TC "
iWinTitleEnd := InStr(sWinTitle, " - ", false, iWinTitleEnd) + 2 ; end of program name
sNewTitle := SubStr(sWinTitle, 1, iWinTitleEnd) . sPath
} else {
sNewTitle := sPath ; set title to path only
}
if (sWinTitle1 != sNewTitle)
if WinActive( "ahk_class TTOTAL_CMD" ) ; prevent affecting other windows
WinSetTitle, %sNewTitle%
}
Return
Back to AutoHotkey