Folder help please (cm_GoToFirstEntry)

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Folder help please (cm_GoToFirstEntry)

Post by *Hacker »

solid,
All internal commands. See totalcmd.inc or execute cm_commandbrowser.

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.
User avatar
solid
Power Member
Power Member
Posts: 747
Joined: 2004-08-09, 11:20 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *solid »

2Hacker
Thx. That is very convenient.
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

Hacker wrote: 2022-03-12, 19:00 UTC linuxy,
Here is an AHK script that reacts to Enter being pressed and after checking if a subdir has been entered sets the focus on the first item:

Code: Select all

Global PreviousTcPath
PreviousTcPath := GetCurrentTcPath()

#IfWinActive, ahk_class TTOTAL_CMD
~$Enter::
	SetTimer, StopChecking, -5000
	SetTimer, CheckAndSetToFirstItem, 50
Return

CheckAndSetToFirstItem()
{
	CurrentTcPath := GetCurrentTcPath()
	If (CurrentTcPath = PreviousTcPath)
		Return
	If ((StrLen(CurrentTcPath) > StrLen(PreviousTcPath)) && InStr(CurrentTcPath, PreviousTcPath))
	{
		SendMessage, 1075, 2049, , , ahk_class TTOTAL_CMD
		SetTimer, CheckAndSetToFirstItem, Off
		SetTimer, StopChecking, Off
	}
	PreviousTcPath := CurrentTcPath
}

StopChecking()
{
	SetTimer, CheckAndSetToFirstItem, Off
}

GetCurrentTcPath()
{
	SendMessage, 1074, 17, , , ahk_class TTOTAL_CMD
	WinGetText, PathInTC, ahk_id %ErrorLevel%
	Return, SubStr(PathInTC, 1, -3) . "\"
}
HTH
Roman
Thank you so much for this. It works. Can you help me tweak the script so it *always* selects the first file/folder in the directory, regardless of when the last time I entered it was? I keep having to enter the same directory twice in order for the AHK script to activate. Sometimes it doesn't at all work. I can't seem to just get it working for any folder, any time. It's hard to predict when this AHK will function. Can you assist>?

I would like it to always activate, please? Thank you kindly.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6490
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Folder help please (cm_GoToFirstEntry)

Post by *Horst.Epp »

Hier my TC button which always goes to the newest entry,
which I find more usefull than the first file.

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
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
LonerD
Senior Member
Senior Member
Posts: 381
Joined: 2010-06-19, 20:18 UTC
Location: Makeyevka, Russia
Contact:

Re: Folder help please (cm_GoToFirstEntry)

Post by *LonerD »

linuxy
Another solution with Autootkey V1.

Set shorcut

Code: Select all

[Shortcuts]
Enter=em_Enter
And user command like

Code: Select all

[em_Enter]
cmd=%commander_path%\Scripts\AutoHotkeyU32.exe "%commander_path%\Scripts\Enter.ahk"
param=%Z%P%N
(with your paths)

Enter.ahk

Code: Select all

#NoEnv
#NoTrayIcon
#SingleInstance force
SetBatchLines, -1

If not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
  ExitApp
WinGet, hw_TTOTAL_CMD, ID, A

; Get Active Panel
SendMessage, 1074, 1000, 0,, ahk_class TTOTAL_CMD
TCPanelA := ErrorLevel
; Get index of first item (0 if there is no updir, 1 otherwise)
SendMessage, 1074, 1008 + TCPanelA, 0,, ahk_class TTOTAL_CMD
TCUpDirAP := ErrorLevel
; Get index of current item (caret)
SendMessage, 1074, 1006 + TCPanelA, 0,, ahk_class TTOTAL_CMD
TCPositionAP := ErrorLevel

SendMessage, 1075, 1001,,, ahk_class TTOTAL_CMD

; If cursor NOT at [..]
if not ( (TCUpDirAP = 1) & (TCPositionAP = 0) )
  TargetFile = %1%
  if InStr(FileExist(TargetFile), "D")
    SendMessage, 1075, 2049,,, ahk_class TTOTAL_CMD

ExitApp

Limitation - Script didn't work in archives.
I don't know way to check if we inside archive or if cursor on archive file.
WM_USER+50 didn't give such information.
But somehow TC can detect it (and even have parameter /A).
"I used to feel guilty in Cambridge that I spent all day playing games, while I was supposed to be doing mathematics. Then, when I discovered surreal numbers, I realized that playing games IS math." John Horton Conway
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

I do appreciate all this help, but it seems silly to go through all this lol just being able to hide/disable the "parent [..]" would make this problem go away I never understand why it's just like toxic and never going to happen. Oh well. :) No need for AHK scripts, or hacks. Maybe someday, I can dream right? lol

Some people are used to (and prefer) when they open a folder, the focus is on the first item/folder in the directory. Not a pair of dots [..] that literally bring you right back out up a directory lol this is the default in Windows, Linux, OSX, hehe. But TC is special!
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

Horst.Epp wrote: 2023-06-07, 20:15 UTC Hier my TC button which always goes to the newest entry,
which I find more usefull than the first file.

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
Can you please tell me where to paste this button code? Thank you!
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *tuska »

Create a Button in the Buttonbar (copy/paste CODE)
  1. Click on "SELECT ALL" (to the right of CODE:), then press CTRL+C (copy to clipboard).
  2. Right-click on any place in the button bar, then click on "Paste".
     ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  3. Option1: Point to the new button (slightly longer): 'Tooltip' is shown (-> description to the button).
                  A maximum of 259 characters is allowed for the tooltip. | = create line break, || = create | as separator character.
  4. Option2: Button bar - "Tooltip" field: A single space deactivates the display of the tooltip.
                  If the "Tooltip" field is empty, the content of the "Command" field is displayed.
  5. Option3: See FAQs and explanation: Button-code (TOTALCMD#BAR#DATA)  <-- <Ctrl+click on the link...>
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3295
Joined: 2003-05-06, 11:46 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *Sir_SiLvA »

linuxy wrote: 2023-06-08, 00:35 UTC But TC is special!
WRONG! Its default two panel filemanager behaviour since Dos & Norton Commander :!:
Hoecker sie sind raus!
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

Sir_SiLvA wrote: 2023-06-08, 01:41 UTC
linuxy wrote: 2023-06-08, 00:35 UTC But TC is special!
WRONG! Its default two panel filemanager behaviour since Dos & Norton Commander :!:
lol what? I know, silly. :) I was complimenting TC for being special. Two panel is great.
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

tuska wrote: 2023-06-08, 00:40 UTC
Create a Button in the Buttonbar (copy/paste CODE)
  1. Click on "SELECT ALL" (to the right of CODE:), then press CTRL+C (copy to clipboard).
  2. Right-click on any place in the button bar, then click on "Paste".
     ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  3. Option1: Point to the new button (slightly longer): 'Tooltip' is shown (-> description to the button).
                  A maximum of 259 characters is allowed for the tooltip. | = create line break, || = create | as separator character.
  4. Option2: Button bar - "Tooltip" field: A single space deactivates the display of the tooltip.
                  If the "Tooltip" field is empty, the content of the "Command" field is displayed.
  5. Option3: See FAQs and explanation: Button-code (TOTALCMD#BAR#DATA)  <-- <Ctrl+click on the link...>
I did that but I can't find where to paste it all. Parameters? code? Command?

Thanks!
User avatar
petermad
Power Member
Power Member
Posts: 14807
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Folder help please (cm_GoToFirstEntry)

Post by *petermad »

did that but I can't find where to paste it all. Parameters? code? Command?
You do not open a button and paste anyting - you simply copy the code - for example:

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
by clicking "select all" in the top of the box here above, and press Ctrl+C . Then you go to TC, right-click on an empty spot on your buttonbar and choose "Paste" - Then TC will make the button for you.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

petermad wrote: 2023-06-08, 01:55 UTC
did that but I can't find where to paste it all. Parameters? code? Command?
You do not open a button and paste anyting - you simply copy the code - for example:

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe
/k "for /f "usebackq delims=" %%f in (`dir /b /a-d /o-d`) do start "" "%%COMMANDER_EXE%%" /O /S /L="%%~ff\:" & exit"
C:\Tools\Wincmd\Icons\Down-Blue.ico
Newest File

1
-1
by clicking "select all" in the top of the box here above, and press Ctrl+C . Then you go to TC, right-click on an empty spot on your buttonbar and choose "Paste" - Then TC will make the button for you.
Oh wow, I never knew that! That's amazing!! Thanks for that tip :)
linuxy
Junior Member
Junior Member
Posts: 33
Joined: 2022-03-03, 22:07 UTC

Re: Folder help please (cm_GoToFirstEntry)

Post by *linuxy »

Hacker wrote: 2022-03-12, 19:00 UTC linuxy,
Here is an AHK script that reacts to Enter being pressed and after checking if a subdir has been entered sets the focus on the first item:

Code: Select all

Global PreviousTcPath
PreviousTcPath := GetCurrentTcPath()

#IfWinActive, ahk_class TTOTAL_CMD
~$Enter::
	SetTimer, StopChecking, -5000
	SetTimer, CheckAndSetToFirstItem, 50
Return

CheckAndSetToFirstItem()
{
	CurrentTcPath := GetCurrentTcPath()
	If (CurrentTcPath = PreviousTcPath)
		Return
	If ((StrLen(CurrentTcPath) > StrLen(PreviousTcPath)) && InStr(CurrentTcPath, PreviousTcPath))
	{
		SendMessage, 1075, 2049, , , ahk_class TTOTAL_CMD
		SetTimer, CheckAndSetToFirstItem, Off
		SetTimer, StopChecking, Off
	}
	PreviousTcPath := CurrentTcPath
}

StopChecking()
{
	SetTimer, CheckAndSetToFirstItem, Off
}

GetCurrentTcPath()
{
	SendMessage, 1074, 17, , , ahk_class TTOTAL_CMD
	WinGetText, PathInTC, ahk_id %ErrorLevel%
	Return, SubStr(PathInTC, 1, -3) . "\"
}
HTH
Roman
This works great, but it only works every *other* time, why is that? Like, when I go in and out of a folder, twice. It works every other folder instance. How can I make it always perform this action, not just every other instance or?

Thanks! :)
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Folder help please (cm_GoToFirstEntry)

Post by *Hacker »

linuxy,
So do I understand correctly, that when you are in C:\UpFolder\SubFolder, and go up to C:\UpFolder, you want the cursor not to be placed on SubFolder, but on the first item in UpFolder?

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.
Post Reply