AutoHotkey: Show the active path in the title bar extended: Difference between revisions
Jump to navigation
Jump to search
((created)) |
(Update for TC 9.50 (changed control for current path)) |
||
Line 7: | Line 7: | ||
#SingleInstance, Force | #SingleInstance, Force | ||
#Persistent | #Persistent | ||
; *** Path In WinTitle V1.02 - (W) STQ 2009-2019 | |||
boAppendToOrgTitle := 1 ; 1 = keep RunAs-user and TC version in title | if FileExist("TC_ActivePathInWinTitle.ico") | ||
boShortenTcName := | 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" | sTcTitleName1 := "Total Commander" | ||
Line 22: | Line 27: | ||
if WinActive( "ahk_class TTOTAL_CMD" ) | if WinActive( "ahk_class TTOTAL_CMD" ) | ||
{ | { | ||
ControlGetText, sPath, TMyPanel3 | 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 = "") | If (sPath = "") | ||
ControlGetText, sPath, TMyPanel2 | ControlGetText, sPath, TMyPanel2 | ||
Line 28: | Line 35: | ||
WinGetTitle, sWinTitle1 | WinGetTitle, sWinTitle1 | ||
if (sWinTitle1 = "") | if (sWinTitle1 = "") | ||
Return ; could not get current title - wait for next run | Return ; *** could not get current title - wait for next run | ||
sWinTitle := sWinTitle1 | sWinTitle := sWinTitle1 | ||
; *** title is reset after minimizing - find out current state | ; *** title is reset after minimizing - find out current state | ||
if (iTitlePos | if (iTitlePos := InStr(sWinTitle, sTcTitleName1 . " ")) | ||
sTcTitleName := sTcTitleName1 | sTcTitleName := sTcTitleName1 | ||
else | else | ||
if (iTitlePos := InStr(sWinTitle, sTcTitleName2 . " ")) | if (iTitlePos := InStr(sWinTitle, sTcTitleName2 . " ")) | ||
sTcTitleName := sTcTitleName2 | sTcTitleName := sTcTitleName2 | ||
; *** shorten original program name | |||
; "user - Total Commander... - regname or path" | ; "user - Total Commander... - regname or path" | ||
if (boShortenTcName) | if (boShortenTcName) | ||
{ | { | ||
Line 51: | Line 58: | ||
if (boAppendToOrgTitle) | if (boAppendToOrgTitle) | ||
{ | { | ||
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 { |
Revision as of 13:58, 21 December 2019
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