AHK script for current dir in titlebar

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
darren1234
Junior Member
Junior Member
Posts: 42
Joined: 2017-09-21, 10:35 UTC

AHK script for current dir in titlebar

Post by *darren1234 »

trawling the forums i found this autohotkey script for displaying the current dir in the titlebar

Code: Select all

#Persistent 

SetTimer subTimer, 250 

Return 
#IfWinActive 

subTimer: 
if WinActive( "ahk_class TTOTAL_CMD" ) 
{ 
ControlGetText sPath, TMyPanel3 
IF (sPath = "") 
   ControlGetText sPath, TMyPanel2 
StringMid sPath, sPath, 1, StrLen(sPath) -1 
WinGetTitle sWindowTitle 
if ( sWindowTitle != sPath ) 
WinSetTitle %sPath% 
} 
Return 
Only problem is it does not work - it just clears the titlebar. Anyone have a fix please?
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Post by *hi5 »

You probably use the 64-bit version, that means the classes are different, if you replace TMyPanel2 and TMyPanel3 with Window11 and Window16 it may work (not sure if these class names are consistent but worth a try).

You can find these classes by starting the Window Spy (right click AHK tray icon) and move your mouse over the control where the path is displayed (that rectangle below the tabs)
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
Stefan2
Power Member
Power Member
Posts: 4158
Joined: 2007-09-13, 22:20 UTC
Location: Europa

AutoHotkey TC Path contol TMyPanel3 TPathPanel2

Post by *Stefan2 »

Also Window7 was reported by tuska for 64-bit TC some time ago,

the controls get a default name from the compiler and are numbered in serial
... just try exchanging the numbers itself on those control labels.



BTW, with AU3_Spy.exe I get TPathPanel 1 and 2 on Win7/32 for TC 8.51
but that above script with TMyPanel 2 and 3 nevertheless works for me.


Also it depends if "Layout > [X]Drive Combobox" is activated or not. Maybe on other GUI-settings too?
There is a old thread where I have shown that up.





 
User avatar
tuska
Power Member
Power Member
Posts: 3758
Joined: 2007-05-21, 12:17 UTC

Post by *tuska »

This code works for me under TC 9.10ß3 - 32 bit + 64 bit, Windows 10 Pro (x64) Version 1703 (Build 15063.632) -
ONLY path of ACTIVE panel is shown! Also works when multiple TC instances are used.

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
Reference: http://ghisler.ch/board/viewtopic.php?p=316158#316158
Last edited by tuska on 2017-10-07, 16:38 UTC, edited 1 time in total.
darren1234
Junior Member
Junior Member
Posts: 42
Joined: 2017-09-21, 10:35 UTC

Post by *darren1234 »

Window10 and Window15 work on the x64, but only for one panel. As the other doesn't show empty when not focused. Any solutions ?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

darren1234 wrote:Window10 and Window15 work on the x64, but only for one panel. As the other doesn't show empty when not focused. Any solutions ?
What do you mean with only for one panel ?
Of course it can only set the title for the active panel.
There is never more than one active TC panel.
Also what is Windows15,you are the only one with this version.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3758
Joined: 2007-05-21, 12:17 UTC

Path in titlebar for active and inactive panel

Post by *tuska »

2darren1234
Maybe this code fit your needs...
Works for me with TC 9.10ß3 - 64 bit, Windows 10 Pro (x64) Version 1703 (Build 15063.632)
Also works when multiple TC instances are used.

Code: Select all

v_Separator := "   ––––––   " 

#Persistent 
SetTimer, Timer, 250 

Timer: 
If WinActive("ahk_class TTOTAL_CMD") 
{ 
  ControlGetText, v_ActivePath, Window11 
  v_ActivePath := RegExReplace(v_ActivePath, "(.+)>", "$1\") 
  ControlGetText v_LeftPath, Window16 
  v_LeftPath := RegExReplace(v_LeftPath, "(.+\\).*", "$1") 
  ControlGetText v_RightPath, Window16 
  v_RightPath := RegExReplace(v_RightPath, "(.+\\).*", "$1") 
  If (v_ActivePath = v_ActivePathOld && v_LeftPath = v_LeftPathOld && v_RightPath = v_RightPathOld) 
    Return 
  v_InactivePath := (v_ActivePath = v_LeftPath) ? v_RightPath : v_LeftPath 
  v_WinTitle := v_ActivePath . v_Separator . v_InactivePath 
  WinSetTitle, %v_WinTitle% 
  v_ActivePathOld := v_ActivePath 
  v_LeftPathOld := v_LeftPath 
  v_RightPathOld := v_RightPath 
} 
Return
Reference: http://ghisler.ch/board/viewtopic.php?p=322477#322477
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Path in titlebar for active and inactive panel

Post by *Horst.Epp »

tuska wrote:2darren1234
Maybe this code fit your needs...
Works for me with TC 9.10ß3 - 64 bit, Windows 10 Pro (x64) Version 1703 (Build 15063.632)
Also works when multiple TC instances are used.

Code: Select all

v_Separator := "   ––––––   " 

#Persistent 
SetTimer, Timer, 250 

Timer: 
If WinActive("ahk_class TTOTAL_CMD") 
{ 
  ControlGetText, v_ActivePath, Window11 
  v_ActivePath := RegExReplace(v_ActivePath, "(.+)>", "$1") 
  ControlGetText v_LeftPath, Window16 
  v_LeftPath := RegExReplace(v_LeftPath, "(.+\\).*", "$1") 
  ControlGetText v_RightPath, Window16 
  v_RightPath := RegExReplace(v_RightPath, "(.+\\).*", "$1") 
  If (v_ActivePath = v_ActivePathOld && v_LeftPath = v_LeftPathOld && v_RightPath = v_RightPathOld) 
    Return 
  v_InactivePath := (v_ActivePath = v_LeftPath) ? v_RightPath : v_LeftPath 
  v_WinTitle := v_ActivePath . v_Separator . v_InactivePath 
  WinSetTitle, %v_WinTitle% 
  v_ActivePathOld := v_ActivePath 
  v_LeftPathOld := v_LeftPath 
  v_RightPathOld := v_RightPath 
} 
Return
Reference: http://ghisler.ch/board/viewtopic.php?p=322477#322477
Tuskas code works fine for me, yours not at all.
It only shows the statistics from the statusbar and no path at all
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3758
Joined: 2007-05-21, 12:17 UTC

Path in titlebar for active and inactive panel - 32bit

Post by *tuska »

This code works for me with TC 9.10ß3 - 32 bit, Windows 10 Pro (x64) Version 1703 (Build 15063.632)
Also works when multiple TC instances are used.

Code: Select all

v_Separator := "   ––––––   " 

#Persistent 
SetTimer, Timer, 250 

Timer: 
If WinActive("ahk_class TTOTAL_CMD") 
{ 
  ControlGetText, v_ActivePath, TPathPanel1 
  v_ActivePath := RegExReplace(v_ActivePath, "(.+)>", "$1\") 
  ControlGetText v_LeftPath, TPathPanel2 
  v_LeftPath := RegExReplace(v_LeftPath, "(.+\\).*", "$1") 
  ControlGetText v_RightPath, TPathPanel2 
  v_RightPath := RegExReplace(v_RightPath, "(.+\\).*", "$1") 
  If (v_ActivePath = v_ActivePathOld && v_LeftPath = v_LeftPathOld && v_RightPath = v_RightPathOld) 
    Return 
  v_InactivePath := (v_ActivePath = v_LeftPath) ? v_RightPath : v_LeftPath 
  v_WinTitle := v_ActivePath . v_Separator . v_InactivePath 
  WinSetTitle, %v_WinTitle% 
  v_ActivePathOld := v_ActivePath 
  v_LeftPathOld := v_LeftPath 
  v_RightPathOld := v_RightPath 
} 
Return
Reference: http://ghisler.ch/board/viewtopic.php?t=13307 (... german language)

If the following code is added at the end of the script (after "Return"):

Code: Select all

#IfWinActive, ahk_class TTOTAL_CMD 
F10:: 
WinClose 
ExitApp
then after closing of TC [ALT + F4], the AHK script is also terminated and the AHK symbol in the systray is automatically removed.
User avatar
tuska
Power Member
Power Member
Posts: 3758
Joined: 2007-05-21, 12:17 UTC

AHK Class names - TMyPanel?, Window??, TPathPanel?, TC path

Post by *tuska »

Determine the contents of the "ClassNN" field (in this case, the path in TC):
http://www.bilder-hochladen.net/files/big/lwdu-n-bc87.png
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Don't use ClassNN with the x64 version. From my experience it gets assigned by Windows semi-randomly and is often (usually?) different between PC's. If you need to get the panel names for some reason, use this:
08.06.16 Added: Send WM_USER+50 with wparam=1..29 -> returns window handle of control. Controls are: 1=leftlist, 2=rightlist, 3=active list, 4=inactive list, 5=leftheader, 6=rightheader, 7=leftsize, 8=rightsize, 9=leftpath, 10=rightpath, 11=leftinfo, 12=rightinfo, 13=leftdrives, 14=rightdrives, 15=leftpanel, 16=rightpanel, 17=bottompanel, 18=lefttree, 19=righttree, 20=cmdline, 21=curdirpanel, 22=inplaceedit, 23=splitpanel, 24=leftdrivepanel, 25=rightdrivepanel, 26=lefttabs, 27=righttabs, 28=buttonbar, 29=buttonbarvertical (32/64)
This works:

Code: Select all

#IfWinExist, ahk_class TTOTAL_CMD

; Default shortcut is Win-A
$#a::
	SendMessage, 1074, 17
	WinGetText, PathInTC, ahk_id %ErrorLevel%
	StringTrimRight, PathInTC, PathInTC, 3
	Send, {Raw}%PathInTC%\
Return
You can still use the previous code which simply looks for the appropriate string:

Code: Select all

#IfWinExist, ahk_class TTOTAL_CMD

; Default shortcut is Win-A
$#a::
	WinGetText, TCWindowText, ahk_class TTOTAL_CMD
	RegExMatch(TCWindowText, "m).*?(?=>)", PathInTC)
	Send, {Raw}%PathInTC%\
Return
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.
darren1234
Junior Member
Junior Member
Posts: 42
Joined: 2017-09-21, 10:35 UTC

Post by *darren1234 »

Many thanks Hacker that works nicely.
This script will display current (focused) dir in the titlebar on my
windows 10 x64 with TC 9.0a x64

Code: Select all

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

#Persistent 

SetTimer timerRoutine, 250 
Return 

^esc::exitapp ; CTRL + Escape will exit this script
;#NoTrayIcon ; turns off systray icon for this script
#IfWinActive ; turns off ifWinActive

timerRoutine:
	if WinActive( "ahk_class TTOTAL_CMD" )
		{
		SendMessage, 1074, 17 
		WinGetText, PathInTC, ahk_id %ErrorLevel% 
		StringTrimRight, PathInTC, PathInTC, 3 
		pathToDisplay = %PathInTC%		   		
		WinGetTitle currentTitle
		if ( currentTitle != pathToDisplay )
			WinSetTitle %pathToDisplay%
		} 
Return
Post Reply