How to get the list of currently selected files?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

How to get the list of currently selected files?

Post by *zsgm02 »

Can somebody tell me which cm_ command is for getting a pointer to the list of currently selected filenames?

Thanks,
Zoltan
User avatar
Flint
Power Member
Power Member
Posts: 3501
Joined: 2003-10-27, 09:25 UTC
Location: Belgrade, Serbia
Contact:

Post by *Flint »

You can use cm_CopyNamesToClip or cm_CopyFullNamesToClip commands to copy names (or correspondingly - full names) of the selected files to the clipboard as plain text, and then just read the clipboard contents.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 11.03 / Win10 x64
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

Thanks for the hint! Is there another way which leaves the Clipboard contents intact?
Of course I can 1. Save the Clipboard 2. Get the filelist 3. Restore Clipboard, but maybe there is a handy solution.
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2zsgm02
I don't know in which type of application you want to have such a list. In case of a standalone application which only requires the list once you may ask your users to start their application using the %L parameter. Your application gets a filename as parameter which contains all selected paths.
User avatar
Flint
Power Member
Power Member
Posts: 3501
Joined: 2003-10-27, 09:25 UTC
Location: Belgrade, Serbia
Contact:

Post by *Flint »

zsgm02
AFAIK, there is no another solution for a "completely external" program. The only possibility is to place yout program on toolbar or in Start menu and pass to it the parameter, for example, %L: TC will create a temporary file, put full list of the selected files/dirs into this file and replace %L with the full path to this temporary file, so you can get the list from it.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 11.03 / Win10 x64
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

With some editors…

Post by *Clo »

2zsgm02
:) Hello !
- Alas, TC hasn't its own clipboard to save the file-names list from these commands directly…
- However, some text-editors have several local clipboards, for instance this one; that could help :wink:

:mrgreen: Kind regards,
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

Lefteous: my application (which is in fact a Lister plugin) needs this list to allow the user edit a custom tag for multiple files.

Consider the following scenario:
- you have an album in a directory, it has 10 mp3 files
- of course the user wants to fill out the album, artist, year and genre fields at _once_, without the necessity to type the same information for each file.
- the user selects the files in the directory and presses f3
- my Lister plugin pops up, showing the common values for the selected files (e.g. if there was a previously filled tag)
- once the user finished editing, presses 'Save' inside the plugin, which saves the tags to all selected files.

The non-modal behavior of the Lister might be a problem (if the user goes back and changes selection, or, even worse, deletes/moves some of them) - because of this, the plugin will always keep the context of the originally selected files.
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

2Clo: Thanks, I'll look into it.:) However, in this case the Clipboard is just the "temporary transportation channel" - when I got the list of selected files, I'll put back the original content.
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

Update:
I have implemented the backup-the-clipboard/CopyFullNamesToClip/restore-the-clipboard approach, however, it doesn't seem to be an elegant solution.

Moreover, it's not just about the cumbersome implementation of clipboard content manipulating (which can be quite slow, too, depending on the data that the clipboard holds), but it is a serious source of bugs.

For example, if the user invokes the Lister from Search Results (Alt + F7) dialog, then the whole concept doesn't work, since the "copy to clipboard" API obviously uses the Left/Right TC Panel to get the selected files, which is - in this case - wrong.

A solution in TC would be to provide the list of selected files as the parameter of ListLoad function. The list would be 0x0 -separated strings of full filenames, so it doesn't hurt already existing plugins. Or, alternatively, an API would help to get the list of selected files.

I saw other people here in the Developer Forum, who needed this functionality in TC, too - I think it would worth to make it possible to dedicate an API for this in a future release of TC.
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

2Lefteous, 2Flint

I'd like to use this %L thing...however, I don't seem to get the name of the temporary file. I have set the filename of my standalone application in TC as "External Viewer" in Configuration/Operation/Edit/View. I specified the filename as "c:\lister_standalone_app.exe %L" - and I got the %L parameter as it is (as "%L" string). Also TC sent a single selected filename instead of a list.

What's going wrong? Where can I find more information on this %L parameter?
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

zsgm02,
The %L parameter can only be used in the Button Bar or the Start menu. In the Help for these items you can also find its description and other parameters, that can be used.

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.
zsgm02
Junior Member
Junior Member
Posts: 19
Joined: 2005-02-02, 08:55 UTC

Post by *zsgm02 »

Thanks. I'll give up this alternate implementation.:)
I keep the current one, which is the clipboard manipulation and which is working fine - as long as the user knows what the plugin is doing...this is crappy, but I don't see any other way which would make sense and would be user friendly.

Is there a chance in the near future that TC will natively support this feature (by an API for example)?
Post Reply