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 (TC instance number, RunAs-user, TC version).
To get more space it can shorten the program name from "Total Commander" to "TC" (optionally).
#SingleInstance, Force
#Persistent
; *** Path In WinTitle V1.02 - (W) STQ 2009-2019
if FileExist("TC_ActivePathInWinTitle.ico")
Menu, Tray, Icon, TC_ActivePathInWinTitle.ico
Menu, Tray, Tip , TC - Path In WinTitle V1.02 - (W) STQ 2009-2019
boAppendToOrgTitle := 1 ; *** 1 = keep RunAs-user and TC version in title
boShortenTcName := 1 ; *** 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, TMyPanel4 ; *** TC9.50 w/ FTP-connection
If (sPath = "")
ControlGetText, sPath, TMyPanel3 ; *** TC9.50 w/o FTP-connection / TC9.22a regardless of FTP-connection
If (sPath = "")
ControlGetText, sPath, TMyPanel2
sPath := SubStr(sPath, 1, StrLen(sPath) - 1)
WinGetTitle, sWinTitle1
if (sWinTitle1 = "")
Return ; *** could not get current title - wait for next run
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
; *** shorten original program name
; "user - Total Commander... - regname or path"
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