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
ND
Member
Member
Posts: 150
Joined: 2006-04-10, 16:24 UTC
Location: Sibiu, RO

Post by *ND »

I'm using the v3.1 script with the latest changes, and I tested on two different systems.

On Win 7 Ultimate (x64):
- AHK v1.0.48.05 => behavior below
- AHK_L v1.0.48.05.L55 (x64) => similar behavior (I had updated to revision 58 in the meantime, so I don't have detailed results)
- AHK_L v1.0.48.05.L58 (x64 / x32 Unicode / x32 ANSI) => crash after TC close / at script exit

On WinXP Pro SP3 (x32):
- AHK v1.0.48.05 => behavior below
- AHK_L v1.0.48.05.L58 (x32 Unicode) => behavior below

TC 7.55a:
- left panel = C:\
- right panel = D:\

initially =>
Total Commander 7.55a - User Name

on script start =>
[1] C:\ -::- TC 7.55a - User Name
after refresh (Ctrl+R) =>
[1] C:\ -::- TC 7.55a - User Name
after change panel (TAB) =>
[1] D:\ -::- TC 7.55a - User Name

after TC close + restart =>
[2] C:\ -::- TC -
after refresh (Ctrl+R) =>
[1] C:\ -::- TC 7.55a - User Name
after change panel (TAB) =>
[2] D:\ -::- TC -

after TC close + restart =>
[3] C:\ -::- TC 0 - 0
after refresh (Ctrl+R) =>
[1] C:\ -::- TC 7.55a - User Name
after change panel (TAB) =>
[3] D:\ -::- TC 0 - 0

after TC close + restart =>
[4] C:\ -::- TC 0 - 0
after refresh (Ctrl+R) =>
[1] C:\ -::- TC 7.55a - User Name
after change panel (TAB) =>
[4] D:\ -::- TC 0 - 0

Note that after fisrt restart the TC version and User Name are empty strings, and after consecutive restart they're "0".
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 »

@ ND: Thanks for the detailed info. Very easy to find the problem. Checked the script's variables after a couple TC Start/Restarts -- I forgot two arrays in the DeleteStruct() function.

I've tested with multiple TC start/restarts, and with multiple instances running and closing them in varied orders. As far as I can tell -- it appears to be working like it _USED_ to before I split up the overloaded _SETGLOBALS() function (and let a couple bugs creep in).
User avatar
ND
Member
Member
Posts: 150
Joined: 2006-04-10, 16:24 UTC
Location: Sibiu, RO

Post by *ND »

Everything looks Ok now.

But I've still removed [face=Courier]tInstance[/face] from [face=Courier]TC_ST2A__FormatTitle()[/face] return value, because I use single TC instance.
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 »

You can just comment the showTCNum1 - and it wont show the instance# for the first running instance of TC (like normal).

Personally, I only use one instance of TC most of the time. If I had of just coded it for my own habits, the script would be much smaller and I would of learned less :-)

One part I really like is if you are running at least two instances and close one that is not the last, all remaining instances will get their titles updated with the proper (current) instance number.

(Version 3.25, but its just clean up, no bug fixes).
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I've added (to my own copy) changing the ButtonBar iconsize when TC's non-maximized width is below a user-definable pixel-width.

The problem is finding where the current wincmd.ini is.

Option 1: Requires SetEnv.exe.
--> Sends a command to TC's Command Prompt to set a Volatile Environment variable (Registry), so that the script can access it.

Option 2: Requires using an AHK script for launching Total Commander.

Option 3: Requires usage of my TC.ahk LIB and adding a User-Command to Total Commander:
em_CMDStart

Command: cmd.exe /c START "%comspec%" /MIN
and optionally check, [X] Run Minimized
Option 1 is the least clean method, yet all pretty much require something external to the stand-alone script.


Development Notes:
Will Release version 3.30 (without the buttonBar feature) that is AHK Library compatible. e.g. will be able to cleanly include into any other AHK Script, and just call the INIT() function.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is finding where the current wincmd.ini is.
To find the wincmd.ini location, you can use the environment variable %COMMANDER_INI% . It's only set in TC itself and all child processes, though.
Author of Total Commander
https://www.ghisler.com
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Yes, to keep it stand-alone, I can basically write an AHK temp-file from the script, and paste the launching of it into TC's Command-Line.

But I think, I'll just require the user to create a small user-command if the ButtonBar feature is to be activated.

Thats the general idea, create a child process (cmd.exe) From which I can grab the COMMAND_INI for each running TC instance. MSDN talks about creating a child-process and modifying its contens -- but for my purposes a background cmd-prompt will work.

Thanks.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Updated to version 3.50
Primarily fix of discovered bug.

Code for ToolBar icon resizing is currently disabled. No clean way to determine location of wincmd.ini for script not started from TC, and conflicts when multiple TC instances are running.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
jathri
Junior Member
Junior Member
Posts: 8
Joined: 2016-08-29, 09:11 UTC

Post by *jathri »

Does not work for me. No active path. Show only this: " :: Total Commander (x64) 8.52a". Could you please look into it? Have AHK 1.1.22.09 64-bit on W7 64-bit.
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Does this script work?

Code: Select all

#Persistent
#NoEnv

WinGetTitle, OriginalTCTitle, ahk_class TTOTAL_CMD
SetTimer, ChangeTCTitle, 1000

ChangeTCTitle:
	WinGetText, TCWindowText, ahk_class TTOTAL_CMD
	RegExMatch(TCWindowText, "m)(?<=^).*?(?=>)", PathInTC)
	WinSetTitle, ahk_class TTOTAL_CMD, , %PathInTC% :: %OriginalTCTitle%
Return
Only works correctly with one instance, though.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
jathri
Junior Member
Junior Member
Posts: 8
Joined: 2016-08-29, 09:11 UTC

Post by *jathri »

This code works for me (show only active folders):

Code: Select all

#Persistent
#NoEnv

WinGetTitle, OriginalTCTitle, ahk_class TTOTAL_CMD
SetTimer, ChangeTCTitle, 1000

ChangeTCTitle:
   WinGetText, TCWindowText, ahk_class TTOTAL_CMD
   PathInTC := TF_Find(TCWindowText, 1, 0, "\*\.\*", 0, 1)
   stringreplace, PathInTC, PathInTC, `n, %a_space%::%a_space%
   stringreplace, PathInTC, PathInTC, *.*,, all
   WinSetTitle, ahk_class TTOTAL_CMD, , %PathInTC% :: %OriginalTCTitle%
Return
TF_Find function is from Textfile & String Library for AutoHotkey (v3.6). But I think it does not matter and you guys see a point.
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

jathri,
But I think it does not matter and you guys see a point.
I don't. What do you need the script to show / do?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
jathri
Junior Member
Junior Member
Posts: 8
Joined: 2016-08-29, 09:11 UTC

Post by *jathri »

Description of TF_Find function:

Code: Select all

TF_Find(Text, StartLine = 1, EndLine = 0, SearchText = "", ReturnFirst = 1, ReturnText = 0)

Purpose: Find text using RegExMatch, return line(s), text or lines and text
Parameters: Text, StartLine, EndLine, SearchText, ReturnFirst, ReturnText

TF_Find(Lines) uses Regular Expressions - This means that if you use certain characters which have a special meaning in a RegEx: *\.\?+[{|()^\$** they must be preceded by a backslash to be seen as literal. For example, \. is a literal period and \\ is a literal backslash. Escaping can be avoided by using \Q...\E. For example: \QLiteral Text\E.

ReturnFirst = 0 return multiple lines
ReturnFirst = 1 return first line only

ReturnText = 0 return line numbers only
ReturnText = 1 return entire line (text). This simulates a basic grep feature
ReturnText = 2 return line numbers + entire line (text). This simulates a basic grep feature

MsgBox % TF_Find("File.txt", "", "", "keys") ; return first line number with keys in it
MsgBox % TF_Find("File.txt", "", "", " c[a-z]+s ", 0, 1) ; find all lines with words that start with a c an end with an s
I would like to see Balderstroms script (first post here) fixed. If I rememeber it correctly I used it for a long time with 32-bit version of TC and everything worked flawlessly. I will be grateful for any help he (you - if Balderstrom himself is reading this post) can provide.
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

jathri,
It seems it does the same thing as my script except for shortening "Total Commander" to "TC" and adding " -::- " between the path and the title instead of " :: "?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
jathri
Junior Member
Junior Member
Posts: 8
Joined: 2016-08-29, 09:11 UTC

Post by *jathri »

Your code (regex?) somehow did not work for me. Maybe I did something wrong. But I hope our previous posts will help Balderstrom to isolate the issue(s). If he is willing, of course.
Post Reply