RESOLVED: Locate the object file dir under cursor at the destination panel and switch to it

English support forum

Moderators: Hacker, petermad, Stefan2, white

igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

RESOLVED: Locate the object file dir under cursor at the destination panel and switch to it

Post by *igarny »

Hello guys,

Please tell if cm_GoToFirstEntry supports parameters for entry name (file or directory)

I would like to get the current entry under cursor, switch to the other panel and find that entry there...

In general I sort my folder on date and time, but even otherwise... it would help me several click every time I want to locate my files in hundreds of other entries.

Also I have tried the direct approach with executing Total Commander from this path or even switching to the specific folder with filename, BUT
the challenge here is to have this working through the SFTP plugin...

Thank you in advance
Last edited by igarny on 2025-03-22, 20:33 UTC, edited 1 time in total.
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

as far as I understand this is impossible with the current implementation: viewtopic.php?t=76713

some sort of other automation, which would type in the letters of the file name in a cm_QuickSearch dialog?

this doesn't work as well: viewtopic.php?t=80677#p446567
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

igarny wrote: 2025-03-21, 16:04 UTC Please tell if cm_GoToFirstEntry supports parameters for entry name (file or directory)
This would not be consistent with the command logic, where the cursor is set according to the current sorting.
igarny wrote: 2025-03-21, 16:04 UTC BUT the challenge here is to have this working through the SFTP plugin...
See 2) in my suggestion.
Overquoting is evil! πŸ‘Ž
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

Thanks @Fla$her

I am somehow not able to reproduce the dollar sign in your name

Thanks for highlighting the problem with cm_GoToFirstEntry

I have checked your topic and now I do remember I tried to deal with this problem and then gave up. You'll see I had been active there. I have now a batch script to traverse to a specific folder location managed by a plugin.

IMHO your use case is a more generalised version of my inquiry / call.
I have my doubts for a solution there, without a more generic power tool like AutoHotKey... see my post there under your topic.

Still I hope I am able to trick TC to locate the filename, which I know Mr. Ghisler already has a solution for it.

My goal:
I have my cursor ar a file in the active panel in a local folder and
want to switch to the same file on the opposite panel often a location under a file system or a packer plugin
this presumably requires some switching, searching and or filtering, for which I seek an automation


I know a solution is already applied by Mr.Ghisler.
Essentially what I am looking for is the solution applied for the cm_CompareFilesByContent.
This command applies a "magic" and can find automatically the file on the opposite panel coming from the same situation:
a file selected by the cursor in the active panel and a folder opened on the opposite panel

and this works within compressed archives and the SFTP plugin
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

igarny wrote: 2025-03-22, 06:31 UTC I am somehow not able to reproduce the dollar sign in your name
In the given topic, see the end of the first page and the beginning of the next one, where you coped with it.
igarny wrote: 2025-03-22, 06:31 UTCI have checked your topic and now I do remember I tried to deal with this problem and then gave up. You'll see I had been active there.
I know we talked there, but I don't see that there was any talk of another panel.
igarny wrote: 2025-03-22, 06:31 UTCI have now a batch script to traverse to a specific folder location managed by a plugin.
I have such a vbs. But I think I'll make the code for Autorun. I'll add an example later in the help.
igarny wrote: 2025-03-22, 06:31 UTCIMHO your use case is a more generalised version of my inquiry / call.
What kind of case are you writing about, I don't understand?
igarny wrote: 2025-03-22, 06:31 UTCEssentially what I am looking for is the solution applied for the cm_CompareFilesByContent.
What you are requesting here is more similar to the commands cm_TransferLeft (like Ctrl+Left) and cm_TransferRight (like Ctrl+Right), i.e. potentially cm_TransferTrg and cm_TransferSrc, which have the same problems from my list for cd, but without considering paths.
Overquoting is evil! πŸ‘Ž
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

Thanks for pointing these commands.
What you are requesting here is more similar to the commands cm_TransferLeft (like Ctrl+Left) and cm_TransferRight (like Ctrl+Right), i.e. potentially cm_TransferTrg and cm_TransferSrc, which have the same problems from my list for cd, but without considering paths
Yes I agree about the essence of the action I am looking for. It is indeed similar.

My point with cm_CompareFilesByContent is the MAGIC
Meaning the solution is known and probably can be derived from the implemented command.

would you suggest I can use TCFS2 to automate:
- get the filename under cursor
- switch to other panel
- invoke cm_QuickSearch
- provide the copied filename as input in the opened dialog for searching
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

igarny wrote: 2025-03-22, 08:15 UTC My point with cm_CompareFilesByContent is the MAGIC
There is no magic there, because it's easier to get paths and names and pass them to the window.
igarny wrote: 2025-03-22, 08:15 UTC would you suggest I can use TCFS2 to automate:
Since we need to save and restore a potential selection in the target panel, TCFS2 is not enough here, as it doesn't have a function for working with the clipboard.
It's easier for me to convert my 5-year-old vbs (it needs an additional dll) into autorun.cfg and post it here. Will it do?
Overquoting is evil! πŸ‘Ž
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

OK. now I understand the confusion I bring with the "magic" reference...
I call magic the ability of the cm_CompareFilesByContent command to locate the file on the remote panel without a selection of files in both panels.

I am looking for the automagic implementation of the first step in the process of the internal command, that finds by itself the correct file in the remote panel.

wrt the VBS, well it is my weak side, but sure I can learn from the master.
Thanks
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

Autorun beta (Installation) and autorun.cfg:

Code: Select all

LoadLibrary Plugins\Autorun_Runtime.dll

#β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
# Purpose:   place the cursor on the item in the target panel with
#            the same item name under the cursor in the active panel
# Condition: em_selectfilesb is needed, with selectfilesb
#            in the first field and %Z%A1 in the second one.
# Parameter: 0 - the target panel will become active.
#β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
RegisterCommand 76549 PlaceCursorOnTheSameNameItemInTargetPanel
RegisterCommand 76550 PlaceCursorOnTheSameNameItemInTargetPanel 0

Func PlaceCursorOnTheSameNameItemInTargetPanel(lParam, SrcFocus=1)
   Local Name, Clip
   Name = GetCurrentItem(3)
   If Name <> GetCurrentItem(4) Then
      IsSelected = RequestInfo(11006)
      SendMessage(RequestInfo(4), 11, 0)
      SendCommand(4006, 0, 1)
      If Name = '..' Then
         If RequestInfo(1009) = 1 And RequestInfo(1010) = 1 Then
            SendCommand(2049, 0, 1)
            SendCommand(2056, 0, 1)
         EndIf
      Else
         If IsSelected Then
            Clip = ClipGet()
            SendCommand(2017, 0, 1)
         EndIf
         SendCommand(524, 0, 1)
         CommandExec('em_selectfilesb', '"' & Name & '"')
         Sleep(10)
         SendCommand(2049, 0, 1)
         SendCommand(2053, 0, 1)
         SendCommand(524, 0, 1)
         If IsSelected Then
            SendCommand(2033, 0, 1)
            ClipPut(Clip)
         EndIf
      EndIf
      SendMessage(RequestInfo(3), 11, 1)
   EndIf
   If SrcFocus Then SendCommand(4006)
EndFunc
Totalcmd.inc:
cm_RightViewMode9=8259;etc. until 8499
cm_SetICurTrgSameNameItem=76549; ICur - inactive cursor
cm_FocusTrgSameNameItem=76550
Last edited by Fla$her on 2025-03-22, 14:39 UTC, edited 1 time in total.
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: cm_GoToFirstEntry

Post by *petermad »

2igarny
I have my cursor ar a file in the active panel in a local folder and
want to switch to the same file on the opposite panel often a location under a file system or a packer plugin
this presumably requires some switching, searching and or filtering, for which I seek an automation
This is what I use in my Extended menus for this task.

Code: Select all

[em_ext_GoToFirstEntry]
cmd=cm_GoToFirstEntry,cm_GotoPrev
menu=Go to first element

[em_ext_SaveSelectionTarget]
cmd=cm_FocusTrg,em_ext_GoToFirstEntry,cm_SaveSelection,cm_ClearAll,cm_FocusTrg

[em_ext_SelectItem]
cmd=SELECTFILESBT
param=%N

[em_ext_goto_item_opositepanel]
cmd=em_ext_SaveSelectionTarget,em_ext_SelectItem,cm_FocusTrg,cm_GotoNextSelected,cm_Unselect -1,cm_RestoreSelection
menu=Go to file/folder with same name in opposite panel if it exists - preserve file selection
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

2petermad
Strangely, on my algorithm, the cm_RestoreSelection didn't work after cm_SaveSelection. I tried to change it now, but it didn't work.
In your case, there is one problem: if you select [..] in the active panel, the cursor will jump to the first folder in the target drive root.
You also need %Z for archives.

By the way, a couple of commands are enough here:

Code: Select all

[em_SelectSameNameItem]
cmd=SELECTFILESB
param="%Z%M"

[em_NavigateToSameNameTrgItem]
cmd=cm_FocusTrg,cm_GoToFirstEntry,cm_GotoPrev,cm_SaveSelection,cm_ClearAll,em_SelectSameNameItem,cm_GotoNextSelected,cm_Unselect -1,cm_RestoreSelection
menu=Navigate to the same name item in the target panel, if exists
Overquoting is evil! πŸ‘Ž
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

Fla$her wrote: 2025-03-22, 11:01 UTC Autorun beta (Installation) and autorun.cfg:

Code: Select all

LoadLibrary Plugins\Autorun_Runtime.dll

#β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
# Purpose:   place the cursor on the item in the target panel with
#            the same item name under the cursor in the active panel
# Condition: em_selectfilesb is needed, with selectfilesb
#            in the first field and %Z%A1 in the second one.
# Parameter: 0 - the target panel will become active.
#β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
RegisterCommand 76549 PlaceCursorOnTheSameNameItemInTargetPanel
RegisterCommand 76550 PlaceCursorOnTheSameNameItemInTargetPanel 0

Func PlaceCursorOnTheSameNameItemInTargetPanel(lParam, SrcFocus=1)
   Local Name, Clip
   Name = GetCurrentItem(3)
   If Name <> GetCurrentItem(4) Then
      IsSelected = RequestInfo(11006)
      SendMessage(RequestInfo(4), 11, 0)
      SendCommand(4006, 0, 1)
      If Name = '..' Then
         If RequestInfo(1009) = 1 And RequestInfo(1010) = 1 Then
            SendCommand(2049, 0, 1)
            SendCommand(2056, 0, 1)
         EndIf
      Else
         If IsSelected Then
            Clip = ClipGet()
            SendCommand(2017, 0, 1)
         EndIf
         SendCommand(524, 0, 1)
         CommandExec('em_selectfilesb', '"' & Name & '"')
         Sleep(10)
         SendCommand(2049, 0, 1)
         SendCommand(2053, 0, 1)
         SendCommand(524, 0, 1)
         If IsSelected Then
            SendCommand(2033, 0, 1)
            ClipPut(Clip)
         EndIf
      EndIf
      SendMessage(RequestInfo(3), 11, 1)
   EndIf
   If SrcFocus Then SendCommand(4006)
EndFunc
Totalcmd.inc:
cm_RightViewMode9=8259;etc. until 8499
cm_SetICurTrgSameNameItem=76549; ICur - inactive cursor
cm_FocusTrgSameNameItem=76550

So I played through the procedure of installing the Autorun plugin....
I see it is very powerful and probably can move mountains for TC especially if it can register new commands...
So far, so good..

I have the Autorun registered as Color scheme >Autorun-color-template, and while doing this I found out that TCFS2tools also has a registration...
I have added the script from Fla$er in the Autorun.cfg file. Restarted TC

Unfortunately I do not find any registrations of new commands in the TC.inc
Then I decided to make a test and went through the documentation. At the end of the HLP file there are examples.
I simply took this one and added it before the script (the LoadLibrary)

Code: Select all

SetHotkeyAction /D /S /K:C /H:N FindFiles 0
Now after restart TC complains with:

"function name not found SetHotkeyAction"

This makes me think Autorun loads, the script loads, but no registration in the tc.inc can be found
igarny
Junior Member
Junior Member
Posts: 74
Joined: 2023-01-26, 19:01 UTC

Re: cm_GoToFirstEntry

Post by *igarny »

Apart of this..
Both solutions based on extended menus work fine in the general usecase which is quite sufficient for me.

I must admit this SELECTFILES modifier is a miss on my side

Thank you for your expertize!
User avatar
petermad
Power Member
Power Member
Posts: 15999
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: RESOLVED: Locate the object file dir under cursor at the destination panel and switch to it

Post by *petermad »

2Fla$her
if you select [..] in the active panel, the cursor will jump to the first folder in the target drive root.
I cannot reproduce that. If I place the cursor on [..] in the active side, the cursor is set on [..] in the target side - but I get an error sound in that case. (tested with a clean ini file)

By the way, a couple of commands are enough here:
Sure - I just also use em_ext_GoToFirstEntry in the menu, and i previously also used em_ext_SaveSelectionTarget for another em_command.

You also need %Z for archives.
If works fine without %Z if the archive is on the target side, and it does not work if the archive is the source (active) side neither with nor without %Z
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: cm_GoToFirstEntry

Post by *Fla$her »

igarny wrote: 2025-03-22, 19:46 UTC Unfortunately I do not find any registrations of new commands in the TC.inc
This makes me think Autorun loads, the script loads, but no registration in the tc.inc can be found
Are you kidding? The specified additives in Totalcmd.inc must be added manually. :mrgreen: And the command numbers can be used without this edit.
igarny wrote: 2025-03-22, 19:46 UTC I simply took this one and added it before the script (the LoadLibrary)

Code: Select all

SetHotkeyAction /D /S /K:C /H:N FindFiles 0
It requires loading Autorun_Tweaks.dll, and in order to avoid other problems, it's logical to load all available libraries at once. I don't write them in every example to avoid duplication.
For general and secondary questions, it's better to contact here - I will answer as much as possible.

petermad wrote: 2025-03-22, 23:48 UTC I cannot reproduce that. If I place the cursor on [..] in the active side, the cursor is set on [..] in the target side
By default, there is no [..] in the drive root.
but I get an error sound in that case.
I have system sounds disabled. But in the script, I check for [..] in both panels to avoid this error.
Sure - I just also use em_ext_GoToFirstEntry in the menu, and i previously also used em_ext_SaveSelectionTarget for another em_command.
It's clear, but in this case, the combination of cm_FocusTrg,em_ext_SelectItem,cm_FocusTrg looks redundant, so I replaced them with one with SELECTFILESB and "%Z%M".
and it does not work if the archive is the source (active) side neither with nor without %Z
You're doing something wrong. Both of my solutions work for me. Edit for your case:
param=%N%Z
Overquoting is evil! πŸ‘Ž
Post Reply