AutoHotkey: Show the active path in the title bar extended: Difference between revisions
Jump to navigation
Jump to search
(Update for TC 9.50 (changed control for current path)) |
(TC 64 bit support + update for TC 9.50 (b11)) |
||
Line 7: | Line 7: | ||
#SingleInstance, Force | #SingleInstance, Force | ||
#Persistent | #Persistent | ||
; | ; //////////////////////////////////////////////////////////////////////////// | ||
; // TC_ActivePathInWinTitle.ahk V1.03 - (W) StatusQuo 2009-2020 | |||
; // | |||
; // show TC's current path in WinTitle | |||
; //////////////////////////////////////////////////////////////////////////// | |||
if FileExist("TC_ActivePathInWinTitle.ico") | if FileExist("TC_ActivePathInWinTitle.ico") | ||
Menu, Tray, Icon, TC_ActivePathInWinTitle.ico | Menu, Tray, Icon, TC_ActivePathInWinTitle.ico | ||
Menu, Tray, Tip , TC - Path In WinTitle V1. | Menu, Tray, Tip , TC - Path In WinTitle V1.03 - (W) STQ 2009-2019 | ||
boAppendToOrgTitle := 1 ; *** 1 = keep RunAs-user and TC version in title | boAppendToOrgTitle := 1 ; *** 1 = keep RunAs-user and TC version in title | ||
Line 27: | Line 31: | ||
if WinActive( "ahk_class TTOTAL_CMD" ) | if WinActive( "ahk_class TTOTAL_CMD" ) | ||
{ | { | ||
ControlGetText, sPath, | ControlGetText, sPath, Window5 ; *** TC9.22a 64bit w/o FTP-connection | ||
If (sPath | If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) ; If (sPath = "") | ||
ControlGetText, sPath, TMyPanel3 ; *** TC9.50 w/o FTP-connection / TC9.22a regardless of FTP-connection | ControlGetText, sPath, Window6 ; *** TC9.50 64bit w/o FTP-connection / TC9.22a w/ FTP-Connection | ||
If (sPath | If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) | ||
ControlGetText, sPath, Window7 ; *** TC9.50 64bit w/ FTP-connection | |||
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) | |||
ControlGetText, sPath, TMyPanel3 ; *** TC9.50 32bit w/o FTP-connection / TC9.22a regardless of FTP-connection | |||
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) | |||
ControlGetText, sPath, TMyPanel4 ; *** TC9.50 32bit w/ FTP-connection | |||
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) | |||
ControlGetText, sPath, TMyPanel2 | ControlGetText, sPath, TMyPanel2 | ||
sPath := SubStr(sPath, 1, StrLen(sPath) - 1) | sPath := SubStr(sPath, 1, StrLen(sPath) - 1) | ||
Line 46: | Line 56: | ||
; *** shorten original program name | ; *** shorten original program name | ||
; "user - Total Commander... - regname or path" | ; "user - Total Commander... - regname or path" | ||
if (boShortenTcName) | if (boShortenTcName) | ||
{ | { | ||
Line 55: | Line 65: | ||
} | } | ||
} | } | ||
if (boAppendToOrgTitle) | if (boAppendToOrgTitle) | ||
{ | { ; *** keep original title part | ||
if (iWinTitleEnd := InStr(sWinTitle, sTcTitleName . " ", true)) ; *** "Total Commander " / "TC " | if (iWinTitleEnd := InStr(sWinTitle, sTcTitleName . " ", true)) ; *** "Total Commander " / "TC " | ||
iWinTitleEnd := InStr(sWinTitle, " - ", false, iWinTitleEnd) + 2 ; *** end of program name | iWinTitleEnd := InStr(sWinTitle, " - ", false, iWinTitleEnd) + 2 ; *** end of program name | ||
sNewTitle := SubStr(sWinTitle, 1, iWinTitleEnd) . sPath | sNewTitle := SubStr(sWinTitle, 1, iWinTitleEnd) . sPath | ||
} else { | } else { ; *** set title to path only | ||
sNewTitle := sPath | sNewTitle := sPath | ||
} | } | ||
if (sWinTitle1 != sNewTitle) | if (sWinTitle1 != sNewTitle) | ||
if WinActive( "ahk_class TTOTAL_CMD" ) ; prevent affecting other windows | if WinActive( "ahk_class TTOTAL_CMD" ) ; *** prevent affecting other windows | ||
WinSetTitle, %sNewTitle% | WinSetTitle, ahk_class TTOTAL_CMD,, %sNewTitle% | ||
} | } | ||
Return | Return |
Latest revision as of 02:29, 2 January 2020
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
; ////////////////////////////////////////////////////////////////////////////
; // TC_ActivePathInWinTitle.ahk V1.03 - (W) StatusQuo 2009-2020
; //
; // show TC's current path in WinTitle
; ////////////////////////////////////////////////////////////////////////////
if FileExist("TC_ActivePathInWinTitle.ico")
Menu, Tray, Icon, TC_ActivePathInWinTitle.ico
Menu, Tray, Tip , TC - Path In WinTitle V1.03 - (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, Window5 ; *** TC9.22a 64bit w/o FTP-connection
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/"))) ; If (sPath = "")
ControlGetText, sPath, Window6 ; *** TC9.50 64bit w/o FTP-connection / TC9.22a w/ FTP-Connection
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/")))
ControlGetText, sPath, Window7 ; *** TC9.50 64bit w/ FTP-connection
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/")))
ControlGetText, sPath, TMyPanel3 ; *** TC9.50 32bit w/o FTP-connection / TC9.22a regardless of FTP-connection
If (not (InStr(sPath, "\"))) and (not (InStr(sPath, "/")))
ControlGetText, sPath, TMyPanel4 ; *** TC9.50 32bit w/ FTP-connection
If (not (InStr(sPath, "\"))) and (not (InStr(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
}
}
if (boAppendToOrgTitle)
{ ; *** keep original title part
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 { ; *** set title to path only
sNewTitle := sPath
}
if (sWinTitle1 != sNewTitle)
if WinActive( "ahk_class TTOTAL_CMD" ) ; *** prevent affecting other windows
WinSetTitle, ahk_class TTOTAL_CMD,, %sNewTitle%
}
Return
Back to AutoHotkey