Set TitleBar to ActivePath & Append TC Default Title

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Set TitleBar to ActivePath & Append TC Default Title

Post by *Balderstrom »

SetTitleBar2ActivePath.ahk --- Version 3.50

If there's any interest/need, will release a compiled version.


Note: If the script is started (or reloaded) after TC is already running, and Total Commander's titleBar is not "standard" the script will:
1) Activate TC if not Active.
2) Minimize TC.
3) Restore TC.
This has the effect of Resetting Total Commander's TitleBar to default.
So the script can grab TC's version# and registered owner's Name.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;	File:	TC_ST2A.ahk 	(TC_SetTitleToActive)
;; 
;;	Version: 3.50	Date: Mar.2011
;; AHK_L compatible, removed DOT concatenation of strings.
;;	 
;;	Requires: Autohotkey: 1.0.48 - February 25, 2009
;; 
;;	Author: Balderstrom, aka Crash&Burn
;;
;;
;;	From AHK Boards: http://www.autohotkey.com/forum/viewtopic.php?t=61979
;;	:: 
;;	:: Modified RegisterCallBack Example by Lexikos, and SKAN's ShellMessages.
;;	::
;;	:: Included: SKAN's ProcessCreationTime() to fix sorting of TC Windows.
;;	::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;	:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:
;;	To Customize title output: See the TC_ST2A__FormatTitle function below.
;;	:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;	Version 3 Notes::
;;		Script utilizes NO HotKeys AND NO Timers. 
;;		Due to the addition of RegisterCallBack(), the minimum AHK version has been increased.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#SingleInstance, Force
	#Persistent
	#NoEnv
SetBatchLInes, -1
SetTitleMatchMode 2
DetectHiddenWindows, ON
OnExit, DeRegisterHooks

WinGet, TC_ST2A__hWnd, ID, %A_ScriptFullPath%
DllCall( "RegisterShellHookWindow", "UInt",TC_ST2A__hWnd ) 
TC_ST2A__MsgNum := DllCall( "RegisterWindowMessage", "Str","SHELLHOOK" ) 
OnMessage( TC_ST2A__MsgNum, "TC_ST2A__ShellMessages" ) 

TC_COUNT := 0
;;
;;	Total Commander Global newLine delimited Strings (PseudoArrays)
;;
T_TC_hwnd		:= ""	; TC hwnd's
T_TC_InSysTray	:= ""	; TC hwnd's in the SystemTray
T_TC_csID		:= ""	; TC hwnd's of TMyPanel3 (Command Prompt|Status)
T_TC_RCB		:= ""	; TC RegisterCallBack pointers	(So we can FREE Them)
T_TC_hHook		:= ""	; TC EventHook IDs				(So we can FREE Them)
T_TC_ownName	:= ""
T_TC_version	:= ""
T_TC_wincmd		:= ""
T_TC_BBMinWidthChange := 1139
T_TC_BBChanged  := FALSE

TC_ST2A__HShellMsgName()
TC_ST2A__INIT( TRUE )	;;	TC_FindALLInstances()
;__ADDEventHook__ObjectCreate()
return


TC_ST2A__FormatTitle( tInstance, tPath, tOwnName, tVersion )
{
	global TC_COUNT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Change this to the string to be appended to TitleBar's SourcePath
;;;	i.e. "     ::     Total Commander "
;;;
	titleTCName := "   -::-   TC "
;;;
;; For the first Running Instance of TC
;; 0 : Do Not Show TC Instance Number
;; 1 : Always Show TC Instance Number
;; 2 :  Only  Show TC Instance Number if more than 1 Copy of TC is Running.
;;;
	showTCNum1 := 2
;;;
	upperCaseDriveLetter := TRUE
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	tcNum := "[" tInstance "]  "
	if( tInstance == 1 && (!showTCNum1 || (showTCNum1 && TC_COUNT < showTCNum1)) )
		tcNum := ""
	
	tPath := ( upperCaseDriveLetter ? UpperChar(tPath, 1) SubStr(tPath, 2, -1) : tPath )
	
return ( tcNum tPath titleTCName tVersion " - " tOwnName )
}


TC_ST2A__TitleReset( wID="", cID="", idx="", path="", ownName="", version="" )
{
	global T_TC_hwnd, T_TC_ownName, T_TC_version
	
	wID := WinExist( !wID ? "A" : "ahk_id " wID )
	
	idx := (idx ? idx : ParseStringN( T_TC_hwnd, wID ))
	idx := (idx ? idx : ParseStringN( T_TC_hwnd, cID ))
	if( !idx )
		MsgBox, % A_ThisFunc " :: No IDX!!"
		
	ownName := ( ownName ? ownName : ParseStringN( T_TC_ownName, "", idx ))
	version := ( version ? version : ParseStringN( T_TC_version, "", idx ))
	if( !path )
		path:=TC_QueryPathA(wID) ; ControlGetText, path, TMyPanel3, ahk_id %wID%
		
	title := TC_ST2A__FormatTitle( idx, path, ownName, version )
	WinSetTitle, ahk_id %wID%,, %title%
return
}


ControlGet( byRef cmdOut, aControl, param1="", param2="", param3="", param4="" )
{
	StringSplit, cmd, cmdOut, #
	if( aControl + 0 )
		ControlGet, cmdOut, % cmd1, % cmd2,, %aControl%, % (param2 + 0 ? "ahk_id " param2 : param2), %param3%, %param4%
	else
		ControlGet, cmdOut, % cmd1, % cmd2,  %aControl%, % (param1 + 0 ? "ahk_id " param1 : param1), %param2%, %param3%, %param4%
return (cmdOut)
}


ControlGetText( byRef aText, aControl, aWin="A", winText="", notTitle="", notText="" )
{
	if( aControl + 0 )
		ControlGetText, aText,, ahk_id %aControl%
	else
		ControlGetText, aText, %aControl%, % (aWin+0 ? "ahk_id " aWin : aWin), %winText%, %notTitle%, %notText%
return aText
}



TC_QueryPathA(wID, byRef pathID="") {
	return ControlGetText(cText, pathID ? pathID : pathID:=TC_QueryPathID(wID))
}


TC_QueryPathID(wID) {
	Loop, 3
		if(">" == SubStr(ControlGetText(cText, "TMyPanel" (A_Index + 2), wID), 0))
			return ControlGet(pathID:="HWND",  "TMyPanel" (A_Index + 2), wID)
return (pathID)
}



UpperChar( cStr, cPos )
{
	cStr := SubStr(cStr, cPos, 1)
	StringUpper, cStr, cStr
return cStr
}


;;
;;	ParseStringN()
;;	::	Parse a newline delimited String ( AHK/Pseudo Array )
;;	::	
;;	::	Returns the index position of the string, 0 if not Found.
;;	OR	Returns the string @ index position "idx"
;;	::
;;	::	NOTE:: idx var overides sFind for what matching is performed.
;;	::
ParseStringN( T_stringN, sFind="", idx=0, removeFound=FALSE )
{
	retVal := ( idx ? 0 : "" )
	sLen:=0
	if( idx )
	{
		Loop, Parse, T_stringN, `n
		{
			sLen += 1 + strlen(A_LoopField)
			if( idx == A_Index && (retVal:=A_LoopField) && rvLen:=strlen(A_LoopField) )
				break
		}
	}
	else
	{
		Loop, Parse, T_stringN, `n
		{
			sLen += 1 + strlen(A_LoopField)
			if( sFind == A_LoopField && (retVal:=A_Index) && rvLen:=strlen(A_LoopField) )
				break
		}
	}

	if( removeFound )
		T_stringN:=substr(T_stringN, 1, sLen - rvLen - 1) substr(T_stringN, sLen + 1)
return retVal
}


TC_ST2A__GETTitlePart( wID, byRef ownName, byRef version )
{
	pass := 0
	if( !WinActive( "ahk_id " wID ) )
		WinActivate, ahk_id %wID%
	ST2A__GetTitlePart:
	WinGetTitle, aTitle, ahk_id %wID%
	RegExMatch( aTitle, "(\[(\d+)\] )?(.* - )?Total Commander (.*) - (.*)$", titleTC )
	ownName	:= titleTC5
	version := titleTC4

	if( !ownName || !version )
	{
		if( pass <> 0 )
		{
			MsgBox, Error cannot get Total Commander's Title
			Exit
		}
		++pass	
		WinMinimize, ahk_id %wID%
		WinActivate, ahk_id %wID%
		Sleep, 100
		goto, ST2A__GetTitlePart
	}
return
}


TC_ST2A__CreateStruct( wID, index=0 )
{
static
	global TC_COUNT, T_TC_ownName, T_TC_version, TC_TCINI
	global T_TC_hwnd, T_TC_csID, T_TC_hHook, T_TC_RCB, T_TC_xWyH
	local cID, ownName, version, wincmd
	static init:=0

	if( !init && init:=1 )
	{
		local globalVars, gVar
		
		globalVars:="T_TC_ownName,T_TC_version,T_TC_hwnd,T_TC_csID,T_TC_hHook,T_TC_RCB"
		Loop, Parse, globalVars, `,
			gVar := A_LoopField, %gVar% := ""
		TC_COUNT:=0
	}
	
	TC_QueryPathA(wID, cID:="")
;	ControlGet, cID, Hwnd,, TMyPanel3, ahk_id %wID%
	wID += 0	; Make sure Decimal format
	cID += 0	; Make sure Decimal format

	if( !ParseStringN(T_TC_hwnd, wID) && ++TC_COUNT )
	{	; New Instance of TC Started
	
		T_TC_hwnd .= wID "`n"		; Update TotalCMDR hwnd's
		T_TC_csID .= cID "`n"		; Update TMyPanel3 hwnd's

		TC_ST2A__GETTitlePart( wID, ownName, version )
		T_TC_ownName .= ownName "`n"
		T_TC_version .= version "`n"
		
/*
		if( !wincmd%version% )	; STATIC Variable
		{
			TC_EMC( "em_CMDSTART cmd.exe /c START ""em_RUN_TC_ST2A"" /MIN setenv.exe -v TC_" wID "_wincmd "`"%%COMMANDER_INI%%`", "", "ahk_id " wID ) 
			WinWaitClose, em_RUN_TC_ST2A ahk_class ConsoleWindowClass
			RegRead, wincmd, HKEY_CURRENT_USER, Volatile Environment, TC_%wID%_wincmd
			wincmd%version% := wincmd
		}
*/
		TC_ST2A__ADDEventHook( wID, R_hHook, R_tcRCB )
		T_TC_hHook	.= R_hHook "`n"	; Update hHook
		T_TC_RCB 	.= R_tcRCB "`n"	; Update RegisterCallBack pointer LIST
		TC_ST2A__TitleReset( wID, "", TC_COUNT, "", ownName, version )
		
	}
	else
	{
		MsgBox, %A_ThisFunc% :: Error, Attempting to Add the same TC Instance again.
		Exit
	}
return
}


TC_ST2A__DeleteStruct( wID="", DX=0 )
{
	global TC_COUNT, T_TC_ownName, T_TC_version
	global T_TC_hwnd, T_TC_csID, T_TC_hHook, T_TC_RCB

	index := (DX ? DX : ParseStringN( T_TC_hwnd, wID, 0, TRUE ))
	ParseStringN( T_TC_csID,    "", index, TRUE )	; Version 3.2 Fix
	ParseStringN( T_TC_ownName, "", index, TRUE )	; Remove index-Position from Array
	ParseStringN( T_TC_version, "", index, TRUE )	; Remove index-Position from Array
	i := index - 1
	Loop, % TC_COUNT - index
		TC_ST2A__TitleReset(ParseStringN( T_TC_hwnd, "", A_Index + i ))

	hHook := ParseStringN( T_TC_hHook, "", index, TRUE )	; RemoveFound=TRUE, ReturnField=TRUE
	tcRCB := ParseStringN( T_TC_RCB,   "", index, TRUE )	; RemoveFound=TRUE, ReturnField=TRUE
	TC_ST2A__UnHookEvent( hHook, tcRCB )
	
	--TC_COUNT
return
}


TC_ST2A__INIT( preINIT=TRUE )	;TC_FindALLInstances( EnumerateSysTray=FALSE )
{
	global T_TC_InSysTray, TC_TCINI
	T_TC_InSysTray := ""
	WinGet, wIDTray, list, , , ahk_class Shell_TrayWnd
	Loop, %wIDTray% 
	{ 
		thisID := wIDTray%A_Index%
		WinGetClass, thisClass, ahk_id %thisID%
		if( thisClass <> "TTOTAL_CMD" ) 
			continue
		WinGetTitle, aTitle, ahk_id %thisID%
		WinGet, tcPID, PID, ahk_id %thisID%
		tc_CTList .= ProcessCreationTime( tcPID ) "," thisID "`n"
	}

	Sort, tc_CTList, N

	Loop, Parse, tc_CTList, `n
	{
		if( !A_LoopField )
			break
		Loop, Parse, A_LoopField, `,
			thisID := ( A_Index == 2 ? A_LoopField : "" )
		if( preINIT )
			TC_ST2A__CreateStruct( thisID + 0, A_Index )
		DetectHiddenWindows, OFF
		T_TC_InSysTray .= ( WinExist("ahk_id " thisID) ? "" : thisID + 0 "`n" )
		DetectHiddenWindows, ON
	}
return
}


ProcessCreationTime( PID ) {                        ; Requires AutoHotkey v1.0.46.03+ 

 VarSetCapacity(PrCT,16)  ,  VarSetCapacity(Dummy,16)  ,  VarSetCapacity(SysT,16) 

 AccessRights := 1040       ; PROCESS_QUERY_INFORMATION = 1024,  PROCESS_VM_READ = 16 
 hPr:=DllCall( "OpenProcess", Int,AccessRights, Int,0, Int,PID ) 
 DllCall( "GetProcessTimes" , Int,hPr, Int,&PrCT, Int,&Dummy, Int,&Dummy, Int,&Dummy) 
 DllCall("CloseHandle"      , Int,hPr) 

 DllCall( "FileTimeToLocalFileTime" , Int,&PrCT, Int,&PrCT )  ; PrCT is Creation time 
 DllCall( "FileTimeToSystemTime"    , Int,&PrCt, Int,&SysT )  ; SysT is System Time 

 Loop 16   {       ; Extracting and concatenating 8 words from a SYSTEMTIME structure 
  Word := Mod(A_Index-1,2) ? "" :  *( &SysT +A_Index-1 ) + ( *(&SysT +A_Index) << 8 ) 
  Time .= StrLen(Word) = 1 ? ( "0" Word ) : Word  ; Prefixing "0" for single digits 
           } 
Return SubStr(Time,1,6) SubStr(Time,9) ; YYYYMMDD24MISS 
}


TC_ST2A__ADDEventHook( wID, byRef hHook, byRef tcRCB )
{
	WinGet, tcPID, PID, ahk_id %wID%

	hHook := DllCall("SetWinEventHook", "uint", 0x800C, "uint", 0x800C 
				, "uint", 0
				, "uint", tcRCB := RegisterCallback("TC_ST2A__ObjectChange") 
				, "uint", tcPID		; idProcess (0=all) 
				, "uint", 0
				, "uint", 0 )
return
}

TC_ST2A__BBIconSize()
{
	TC_BBICONSIZE := 5 + (( (tcWidth - 8) == A_ScreenWidth && (tcHeight - 8) == A_ScreenHeight ) ? 24 : 32 )
return
}

TC_ST2A__ObjectChange( hWinEventHook, event, hwnd, idObject, idChild, thread, time ) 
{
static
	global T_TC_csID, T_TC_hwnd, T_TC_BBMinWidthChange, T_TC_BBChanged
	local idx
;	local EVENT_OBJECT_LOCATIONCHANGE := 0x0000800B
	local EVENT_OBJECT_NAMECHANGE     := 0x0000800C
	local tcWidth
/*
	if( event == EVENT_OBJECT_LOCATIONCHANGE && T_TC_BBMinWidthChange )
	{
		if( !ParseStringN( T_TC_hwnd, hwnd ) )
			return
		WinGetPos,,, tcWidth,,, ahk_id %hwnd%
		if( tcWidth < T_TC_BBMinWidthChange )
			TC_ST2A__BBIconSize()
	return
	}
*/
	if( idx := ParseStringN( T_TC_csID, hwnd ))
	{
		ControlGetText, cText%hwnd%,, ahk_id %hwnd%
		if( cText%hwnd% == cTextLast%hwnd% )
			return
		cTextLast%hwnd% := cText%hwnd%
		TC_ST2A__TitleReset( "", hwnd, idx, cText%hwnd% )
	}
	else
	if( idx := ParseStringN( T_TC_hwnd, hwnd ))
		TC_ST2A__TitleReset( hwnd, "", idx, cTextLast%hwnd% )
return
}


TC_ST2A__ShellMessages( wP,lP ) 
{
	global T_TC_InSysTray

	routine := TC_ST2A__HShellMsgName( wP )
	
	WinGetClass, aClass, ahk_id %lP%
	
	if( aClass <> "TTOTAL_CMD" )
		return
	
	if( routine == "HSHELL_WINDOWCREATED" ) 
	{
		if( ParseStringN( T_TC_InSysTray, lP, 0, TRUE ) )
			return
		else
			TC_ST2A__CreateStruct( lP + 0 )
	}
	else
	if( routine == "HSHELL_WINDOWDESTROYED" )
	{
		Sleep, 100
		TC_ST2A__INIT( FALSE )	; Update T_TC_InSysTray
		if(!inStr( T_TC_InSysTray, lP "`n" )) 
			TC_ST2A__DeleteStruct( lP + 0 )
	}
return
}


TC_ST2A__HShellMsgName( msgNum="" )
{
	static
	static init := 0
	local msgName
	
	if( !init && init := 1 )
	{
		local hMsgNames := " 
			(LTrim Join,  
				HSHELL_WINDOWCREATED
				HSHELL_WINDOWDESTROYED 
				HSHELL_ACTIVATESHELLWINDOW 
				HSHELL_WINDOWACTIVATED 
				HSHELL_GETMINRECT 
				HSHELL_REDRAW 
				HSHELL_TASKMAN 
				HSHELL_LANGUAGE 
				HSHELL_SYSMENU 
				HSHELL_ENDTASK 
				HSHELL_ACCESSIBILITYSTATE 
				HSHELL_APPCOMMAND 
				HSHELL_WINDOWREPLACED 
				HSHELL_WINDOWREPLACING 
				HSHELL_HIGHBIT 
				HSHELL_FLASH 
				HSHELL_RUDEAPPACTIVATED 
			)"
			
		Loop, Parse, hMsgNames, `,
		{
			HSHELL__MSG%A_Index% := A_LoopField
		}
		if( msgNum == "" )
			return
	}
return ( msgName := (HSHELL__MSG%msgNum% ? HSHELL__MSG%msgNum% : "UNKNOWN") )
}


TC_ST2A__UnHookEvent( hHook, tcRCB )
{
Critical 
	if( hHook )	
		DllCall("UnhookWinEvent", "Uint", hHook)
	if( tcRCB )
		DllCall("GlobalFree", UInt, &tcRCB )
return
}

DeRegisterHooks:
{
Critical
	MsgBox,,DeRegisterHooks, Deregistering Hooks...,1

	DllCall( "UnhookWinEvent", Uint,hWinEventHook ) 
	DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback 

	DllCall( "DeregisterShellHookWindow", "UInt", TC_ST2A__hWnd )
	Loop, %TC_COUNT%
		TC_ST2A__DeleteStruct( "", A_Index )	; This includes, Unhooking Events.
	ExitApp
}	 


TC_ST2A__ExitScript()
{
	MsgBox,4,%A_ScriptName%::%A_ThisFunc%(),Do you wish to Exit %A_ScriptName%?,4
	ifMsgBox, YES
		ExitApp
	else
	ifMsgBox, TimeOut
		return
return
}

/*	NOTE::
 *	If you disable the SystemTray icon above, then
 *	you should enable a Hotkey to exit the script.
 */
;#ifWinActive, ahk_class TTOTAL_CMD
;{
;	;; ^#!4::TC_ST2A__ExitScript()
;return
;}
v3.50:
* Fix for query to TC's Path (TMyPanel3) ... which can be TMyPanel3, 4 or 5 depending on which Toolbars are active.
+ Partial Code for resizing ToolBar icons (disabled).
v3.25:
* No Bug Fixes. Or Changes. General Code cleanup. Removal of Debug lines and one superfluous global array.

v3.2:
* Fix to DeleteStruct. Two arrays weren't being reset.

v3.1:
* Small Fix, readded Beta versions ProcessCreationTime to properly Sort TC instanceNumbers by time created.

v3.0:
* Complete Rewrite. Requires more recent version of AutoHotKey.
* Fixed all outstanding issues.
* Handles Multiple running Total Commander instances.
* Easier customization of Title output in the FormatTitle function.

v2.0:
*Unreleased.
* Fixed all outstanding issues, except for (1)one:
(1) If a new instance of the script was started,
---- i.e. with a shortcut to launch both - that straggler issue was resolved.

v1.9:
* Fix for multiple instances of TC running (show instance #).
* Removed static variables. Some Formatting fixes/changes. Code Clean-up.

v1.8:
* Removed a Panel-Detection code: no longer needed since path is retrieved from the Command-Prompt/Status.
* Moved the Context-Menu detection to the end of the script.
* Removed Timed CallOUT for Left Click -- back to previous implementation: With the other changes Double-Click is not impeded any longer.

v1.7:
* Changed almost all triggers to "key up", improved efficiency.
* Changed LButton significantly; noticed an oddity with DoubleClick --Rename-in-place was getting triggered for slightly-slower-DoubleClicks.

v1.6:
* Removed WIN+Ctrl+Alt+T, not needed as noted by MVV.
* Added, Ctrl+R trigger, Commented ;F2

v1.5: Implemented MVV suggestion, get Title from Left of Command-Line.

v1.4: Removed While, replaced with if

v1.3: Fix for ContextMenus: which blocked retrieving title with cm_CopySrcPathToClip

v1.2: Fix for changing path via the BreadCrumb, or Editing the Path.

v1.1: Slight Change for TAB, Since Ctrl+Tab, Shift+Ctrl+Tab cycles through FileTABs.
Last edited by Balderstrom on 2011-03-20, 10:49 UTC, edited 23 times in total.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

Thanks for the script!

I think you have to provide the required AutoHotkey version as a comment, because I tried to run it with version 1.0.48.01 but it stops due to this line

Code: Select all

while( !inStr( cFocus, "TMyListBox" ) )
This script requires at least AutoHotkey 1.0.48.04 to run properly.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

RIght, I don't keep much track of which version I'm using as it hasn't been updated in quite some time now.
I plan to try Lexikos branch soon as he has worked support for Win2K in.

I'll just change it to an "IF" it doesn't necessarily need to be 'while' it just makes it more indicative that it is a loop at a glance.

Thanks.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

Fine, the script now can be run with an older AutoHotkey version.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't see F2, Ctrl+R or any other cm_RereadSource processing in your script:) also TC resetting title on restore from tray.

And... it uses clipboard??? IMHO it is much easier to read current path from command line bar.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

There's no need for F2/Ctrl+R processing. When you do those, the title is already set -- the file contents of the current directory may change, but the actual directory wont change just by issuing a cm_ReReadSource.

Path from the Left of the Command-Line Bar is a good idea, thanks.
I usually have the command-line hidden, except on use - so didn't think of/or see that for grabbing the path.

I'm sure there's an exception or two that I haven't considered, but I don't think F2/Ctrl+R is one of them. I'll fix any I've missed, but as is the title does autocorrect itself as soon as you "TAB", Click, RClick, Enter, etc.

One that I know is missing, when a FTP session closes, password not provided, or request to reconnect is denied -- that TAB will change paths - that particular instance isn't accounted for -- and without a timer ( and I don't reall care for persistent timers) I don't see how to resolve that particular discrepancy.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I mean that TC resets title on F2/Ctrl+R:)

Even if command line is hidden you may get path from its path panel.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

@ MVV, Well thats cool, I can get rid of the Hotkey: WIN+CTRL+ALT+T
Since it's purpose was to make sure you could reset the Title if you were going to exit the script.

Updated to V1.7,
F2/Ctrl+R inclusion.
Fixes for DoubleClick, Click and efficiency in General.

Thanks for input.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Final Version, unless new Functionality is needed.

* Removed a chunk of code that was no longer needed since we get the path from Command-Prompt/Status.
* Moved the Context-Menu detection to the end of the script.
* Removed Timed CallOUT for Left Click -- back to previous implementation: With the other changes Double-Click is not impeded any longer.
User avatar
ND
Member
Member
Posts: 150
Joined: 2006-04-10, 16:24 UTC
Location: Sibiu, RO

Post by *ND »

Balderstrom wrote:I'm sure there's an exception or two that I haven't considered,
0. title not set when script is launched
1. title not set when TC is (re)started
2. title not set after Ctrl+W (cm_CloseCurrentTab)
3. title not set on Ctrl+\ (cm_GoToRoot)
4. title not set on BackSpace or Ctrl+PgUp (cm_GoToParent)
5. title not set on Ctrl+PgDn (can be used instead of Enter to enter dirs as well as archives)
6. title not set on Alt+F1 (or Alt+F2) + letter (change left/right drive)
7. title not set after location changed via double Ctl+B (cm_DirBranch) (i.e. set branch view, move cursor to some inner file/dir, reset branch view)
8. title not set on Ctrl+U (cm_Exchange) and Ctrl+Shift+U (cm_ExchangeWithTabs)
9. title not set on Alt+Left (cm_GotoPreviousDir) or Alt+Right (cm_GotoNextDir)

There may be more exceptions for the cm_GoTo... commands, but I don't know their hotkeys.
There may be exceptions related to tree-views, but I don't use those.
aNDreas Bolotă
The truth always carries the ambiguity of the words used to express it. (Frank Herbert, God Emperor of Dune)
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

That's why it is much more easy and effectively to change title just by timer:)
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Version 3.0 Released. ALL Issues Fixed + Improvements.

Version 2.0 was not Released.
--- Almost all issues were fixed. The one straggler issue When launching a new instance of TC, one would need to use a shortcut to launch a new instance of the script (as well) -- which would replace the old running script instance.
Last edited by Balderstrom on 2010-09-03, 20:13 UTC, edited 1 time in total.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Version 3.1 Released. Small fix for TC instanceNumber.
User avatar
ND
Member
Member
Posts: 150
Joined: 2006-04-10, 16:24 UTC
Location: Sibiu, RO

Post by *ND »

Balderstrom wrote:Version 3.1 Released. Small fix for TC instanceNumber.
Because I use single TC instance ("allow only 1 copy of TC at a time"), I have removed [face=Courier]tInstance[/face] handling from [face=Courier]TC_ST2A__FormatTitle()[/face].

But before I did that I noticed that there is a problem: each time after I restarted TC the number was incremented.

Just an idea:
Perhaps this happens because I use TC portable (done with tc2usb tool, i.e. launch TC from starttc.exe in USB drive root, not directly totalcmd.exe).
aNDreas Bolotă
The truth always carries the ambiguity of the words used to express it. (Frank Herbert, God Emperor of Dune)
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I made a small change to the script that I didn't "comment" -- it was fairly soon after 3.1 was originally reposted. And was a typo that occured while splitting the temporary function TC_SETGLOBALS() into TC_ST2A__CreateStruct, and TC_ST2A__DeleteStruct.

--TC_COUNT should be the last line of TC_ST2A__DeleteStruct (before the brace} ) : Do you have that in your copy?

Developer Notes:
As such the Instance-Number stuff was prolly the most problematic, although it did bring about the ParseStringN function -- and I really like the functionality of that. Prior to the ParseStringN Func I was using global "PseudoArrays" like:
TC_%hwnd% := idx, TC_%idx%_@x := %hwnd%, TC_%idx%_@O := owner, etc, etc.
This creates a lot of globals if you run more than one instance of TC or start/restart it -- So I had code to loop through index#'s: clear them if that TC-instance was closed, and re-use that global when another one was needed.

When I got the idea for ParseStringN it simplified all of that significantly: No longer need to track the actual index#s since now the index# can be retrieved by it's position in the new-line delimited string.
Post Reply