Retrieve paths and file lists from Total Commander
Moderators: Hacker, petermad, Stefan2, white
Retrieve paths and file lists from Total Commander
Hi all,
I'm developing an application in .NET from which I would like to access Total Commander and retrieve some data from it. Particularly I'm interested in:
- source path (folder)
- target path (folder)
- file under the cursor in source folder
- all selected files in source folder
- not necessary, but might be handy as well: selected files in target folder, etc.
I know there is a possibility to use SendMessage and execute commands like cm_CopySrcPathToClip, cm_CopyTrgPathToClip and cm_CopyFullNamesToClip. However, these require using clipboard and for various reasons I would like to avoid that. And I didn't find a command to retrieve only file under the cursor if multiple files are selected.
According to thread http://ghisler.ch/board/viewtopic.php?t=32658 it should be possible to use WM_COPYDATA. But if I understand it correctly, I can only query source/target/left/right path, filename under cursor, list count and cursor index. What about list of selected files? Maybe there is an option, but I'm unable to find proper documentation.
Thank you for your suggestions.
I'm developing an application in .NET from which I would like to access Total Commander and retrieve some data from it. Particularly I'm interested in:
- source path (folder)
- target path (folder)
- file under the cursor in source folder
- all selected files in source folder
- not necessary, but might be handy as well: selected files in target folder, etc.
I know there is a possibility to use SendMessage and execute commands like cm_CopySrcPathToClip, cm_CopyTrgPathToClip and cm_CopyFullNamesToClip. However, these require using clipboard and for various reasons I would like to avoid that. And I didn't find a command to retrieve only file under the cursor if multiple files are selected.
According to thread http://ghisler.ch/board/viewtopic.php?t=32658 it should be possible to use WM_COPYDATA. But if I understand it correctly, I can only query source/target/left/right path, filename under cursor, list count and cursor index. What about list of selected files? Maybe there is an option, but I'm unable to find proper documentation.
Thank you for your suggestions.
Re: Retrieve paths and file lists from Total Commander
Search for "New WM_COPYData Examples" in the forum !stalker0 wrote:Hi all,
I'm developing an application in .NET from which I would like to access Total Commander and retrieve some data from it. Particularly I'm interested in:
- source path (folder)
- target path (folder)
- file under the cursor in source folder
- all selected files in source folder
- not necessary, but might be handy as well: selected files in target folder, etc.
I know there is a possibility to use SendMessage and execute commands like cm_CopySrcPathToClip, cm_CopyTrgPathToClip and cm_CopyFullNamesToClip. However, these require using clipboard and for various reasons I would like to avoid that. And I didn't find a command to retrieve only file under the cursor if multiple files are selected.
According to thread ghisler.ch/board/viewtopic.php?t=32658 (sorry, I don't have rights to use URL tag yet) it should be possible to use WM_COPYDATA. But if I understand it correctly, I can only query source/target/left/right path, filename under cursor, list count and cursor index. What about list of selected files? Maybe there is an option, but I'm unable to find proper documentation.
Thank you for your suggestions.
To get le list of selected file you can use a temporary file using %L or %WL with a user command.
If you can stick to 32Bit plenty of AHK / powerpro / Auto-It samples can helps you !
"New WM_COPYData Examples" thread is exactly the one I'm referencing to. But as I mentioned in my first post, information that TCMD is able to return with WM_COPYDATA is quite limited and doesn't fulfill all my needs.
I can use %L, %UL or %WL and pass it as a command line parameter to my application. However I don't need the list during application startup, but on-demand during app lifetime. Or am I missing how to do it? I know there are plenty AHK examples with %L, but all found was use case: TCMD starts AHK script with %L as a parameter.
I can use %L, %UL or %WL and pass it as a command line parameter to my application. However I don't need the list during application startup, but on-demand during app lifetime. Or am I missing how to do it? I know there are plenty AHK examples with %L, but all found was use case: TCMD starts AHK script with %L as a parameter.
What you can do, is to create a user command that copy %L file to a dedicated filename. From your app, you call the user command wait a little, read the file and delete it !stalker0 wrote:...
I can use %L, %UL or %WL and pass it as a command line parameter to my application. However I don't need the list during application startup, but on-demand during app lifetime. Or am I missing how to do it? I know there are plenty AHK examples with %L, but all found was use case: TCMD starts AHK script with %L as a parameter.
You can also create an additionnal command that switch to target, copy, switch back to source....
Not nice but it can do the work... (you can even create user command and delete them on the fly...)
How exactly is it possible with user command to copy %L file? Only solution I see is following:
- create separate application (or script) which will copy file given to it as a command line parameter to some configured location
- create user command which will call this application and pass %L parameter
- my main application will call TCMD (via SendMessage) to execute this user command
- my another app copies temporary %L file to some configured location
- main app scans this location and as soon as there is newly added file, it reads the content (and deletes this temporary file afterwards)
Is this what you suggested?
What I especially don't like about this solution is the fact that I need to create user command in TCMD first, which is kind of showstopper for me (it should work out-of-the-box with any TCMD installation without previous configuration). You wrote that it is possible to create/delete user commands on the fly. That might solve my problem, but so far I didn't find how to do it.
Btw it seems that there already has been similar request.
- create separate application (or script) which will copy file given to it as a command line parameter to some configured location
- create user command which will call this application and pass %L parameter
- my main application will call TCMD (via SendMessage) to execute this user command
- my another app copies temporary %L file to some configured location
- main app scans this location and as soon as there is newly added file, it reads the content (and deletes this temporary file afterwards)
Is this what you suggested?
What I especially don't like about this solution is the fact that I need to create user command in TCMD first, which is kind of showstopper for me (it should work out-of-the-box with any TCMD installation without previous configuration). You wrote that it is possible to create/delete user commands on the fly. That might solve my problem, but so far I didn't find how to do it.
Btw it seems that there already has been similar request.
You get the general picture !stalker0 wrote:How exactly is it possible with user command to copy %L file? Only solution I see is following:
- create separate application (or script) which will copy file given to it as a command line parameter to some configured location
- create user command which will call this application and pass %L parameter
- my main application will call TCMD (via SendMessage) to execute this user command
- my another app copies temporary %L file to some configured location
- main app scans this location and as soon as there is newly added file, it reads the content (and deletes this temporary file afterwards)
Is this what you suggested?
What I especially don't like about this solution is the fact that I need to create user command in TCMD first, which is kind of showstopper for me (it should work out-of-the-box with any TCMD installation without previous configuration). You wrote that it is possible to create/delete user commands on the fly. That might solve my problem, but so far I didn't find how to do it.
Btw it seems that there already has been similar request.

you can make a user command like: em_copyStatic
Code: Select all
command:%COMSPEC% /c
parameter: copy /Y %L "%TEMP%\savedList.lst"
Code: Select all
command:%COMSPEC% /c
parameter: copy /Y %L %A
With the magic of %A you can have additional parameter!
if you want to have a file as parameter, you can add it separated by a ' ' ... like [face=courier]em_copyDyn C:\temp\myFile.txt[/face] as command string 1
I hope it can help !
If you have the right to modify usercmd.ini file you can add it manipulating the file.stalker0 wrote:Ok, thank you. I successfully called both em_copyStatic and em_copyDyn with SendMessage. But still one problem remains: in order to call user command, somebody has to define it first. Is there a way how to do it automatically from my app?
But the best way is to just put a snippet that the user put on his usercmd.ini file or let your app do it with with his consent when you install your applic ation !
- fenix_productions
- Power Member
- Posts: 1979
- Joined: 2005-08-07, 13:23 UTC
- Location: Poland
- Contact:
Isn't it a little bit overcomplicated?
Why would anyone use WM_MESSAGE to call user command which calls system command line which calls copy?
Wouldn't be easier to just skip all middlemen and either call copy from main .NET application or just copy files using .NET methods.
I understand calling user commands if they contain TC-only functions.
Calling them to start other applications is strange (especially if those "other apps" call something more).
Why would anyone use WM_MESSAGE to call user command which calls system command line which calls copy?
Wouldn't be easier to just skip all middlemen and either call copy from main .NET application or just copy files using .NET methods.
I understand calling user commands if they contain TC-only functions.
Calling them to start other applications is strange (especially if those "other apps" call something more).
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...
#128099
#128099
fenix_productions wrote:Isn't it a little bit overcomplicated?
Why would anyone use WM_MESSAGE to call user command which calls system command line which calls copy?
Wouldn't be easier to just skip all middlemen and either call copy from main .NET application or just copy files using .NET methods.
I understand calling user commands if they contain TC-only functions.
Calling them to start other applications is strange (especially if those "other apps" call something more).
You probably missed that we want to have TC building the "selected files" list in a temporary file %L.
I admit that this is a bit over-complicated as TC do not provide SAVESELECTEDTOFILE as a command with parameter

You can also build a copy like windows application that will not be called by the system...
- fenix_productions
- Power Member
- Posts: 1979
- Joined: 2005-08-07, 13:23 UTC
- Location: Poland
- Contact:
2nsp
I did not miss %L information. I am just saying that using user command to call next two steps makes everything even more complicated.
In case I had to write something like that all would depend of final goal:
- to have a list - commadline copy could be the way,
- to do something with list of files - I would call my own app to proceed further, maybe even the very same app which does WM_ calls.
I did not miss %L information. I am just saying that using user command to call next two steps makes everything even more complicated.
In case I had to write something like that all would depend of final goal:
- to have a list - commadline copy could be the way,
- to do something with list of files - I would call my own app to proceed further, maybe even the very same app which does WM_ calls.
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...
#128099
#128099
I wanted to avoid it, but I guess I have no other option.nsp wrote:If you have the right to modify usercmd.ini file you can add it manipulating the file.
But the best way is to just put a snippet that the user put on his usercmd.ini file or let your app do it with with his consent when you install your application !
- fenix_productions
- Power Member
- Posts: 1979
- Joined: 2005-08-07, 13:23 UTC
- Location: Poland
- Contact:
2Hacker
I agree there is no other way than making user command with %L.
I just think we could avoid chaining software (%comspec% and copy) and use given list right away in this "external program" (if further processing is needed).
In worst case scenario I would use Clipboard related TC functions with "save/restore Clipboard state" methods. Or implement both and check which is quicker. There is a chance that Clipboard method may be quicker if there is not a lot of data in it.
But this is just a thought because the best would be to convince Christian to add missing functionality to TC.
I agree there is no other way than making user command with %L.
I just think we could avoid chaining software (%comspec% and copy) and use given list right away in this "external program" (if further processing is needed).
In worst case scenario I would use Clipboard related TC functions with "save/restore Clipboard state" methods. Or implement both and check which is quicker. There is a chance that Clipboard method may be quicker if there is not a lot of data in it.
But this is just a thought because the best would be to convince Christian to add missing functionality to TC.
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...
#128099
#128099
fenix_productions
I wanted to avoid using clipboard. In most cases, it'll work just fine. But imagine there is some other "clipboard enhancement" program running in the background. It'll just add mess to clipboard's history.
And yes, I can bypass %comspec% copy and call directly my application with %L. It would require some additional code in the app startup (if called with parameter -> copy file; otherwise start application normally).
I wanted to avoid using clipboard. In most cases, it'll work just fine. But imagine there is some other "clipboard enhancement" program running in the background. It'll just add mess to clipboard's history.
And yes, I can bypass %comspec% copy and call directly my application with %L. It would require some additional code in the app startup (if called with parameter -> copy file; otherwise start application normally).