[WFX] Call Lister (send cm_List) with parameter - possible?

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

Moderators: Hacker, petermad, Stefan2, white

User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

[WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Dalai »

Hi there,

I had some ideas for my Services2 plugin and I'm currently trying to implement them. One of them involves calling TC Lister with a parameter. Is it possible to do that using PostMessage?

Here's what I tried (not all of them at once of course):

Code: Select all

var s: PString;
begin
    New(s);
    s:= PString(FService.Executable);
    if NOT PostMessage(FhTotalCmd, TotalCmdMsg, cm_List, LParam(s)); then
        Dispose(s);}


    PostMessage(FhTotalCmd, TotalCmdMsg, cm_List, LongInt(PChar(FService.Executable)));


    PostMessage(FhTotalCmd, TotalCmdMsg, cm_List, Integer(@FService.Executable)));
TC receives the message fine in all of the above cases but ignores the executable given by lParam and loads the file under the cursor instead. Is there any way to use PostMessage or some other internal function?

PS: I know that calling

Code: Select all

%COMMANDER_EXE% /S=L <executable>
is possible ...

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

None of cm-commands expect any parameters.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

That's not true. cm_List can take a parameter since Windows Commander 4.50. See for yourself in history.txt:

Code: Select all

New in Version 4.50 (30.6.00):
[...]
- cm_List now allows to open a file. The file name must be given directly behind CM_LIST, and not in the parameters field!
  Example: cm_list c:\windows\wincmd.ini always opens the file wincmd.ini in lister.
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, it is a special interpretation of cm-command call, it can't work via window message of course. TC simply process such button differently. The only way to send a string message is WM_COPYDATA message.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I gave WM_COPYDATA a try but didn't have any luck so far; just nothing happens. My test code:

Code: Select all

var
    Lcds: TCopyDataStruct;
    p: PChar;
begin
//    Lcds.dwData:= cm_List;
//    Lcds.dwData:= 0;
    Lcds.dwData:= Self.Handle;
//    p:= PChar(FService.Executable);
    p:= PChar('cm_List ' + FService.Executable);
    Lcds.cbData:= (StrLen(p) + 1) * SizeOf(Char);
    Lcds.lpData:= p;
    SendMessage(FhTotalCmd, WM_COPYDATA, Integer(Self.Handle), Integer(@Lcds));
end;
I can only guess that TC isn't supposed to react to that message (sent externally)...

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Why not start a standalone copy of lister? That's much easier!

Just call
c:\path\totalcmd.exe /S=L c:\path_to\file_to_view.ext

Have a look at section 4a in the help - you can even set the mode in which Lister should start, or a lister plugin!
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

ghisler(Author) wrote:Why not start a standalone copy of lister? That's much easier!
Yes, I know that as you can see in OP. I already implemented this and it's working perfectly. However, using a separate process has some disadvantages, for example: the separate "Lister process" doesn't close its window when the TC instance in foreground (and my plugin) is closed.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Hurdet
Power Member
Power Member
Posts: 704
Joined: 2003-05-10, 18:02 UTC

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Hurdet »

SEND ("EM" , "cm_list C:\Windows\Temp\_tc\vds.Stopped")
$dwData = Asc("E") + 256 * Asc("M")
is working!

How you create %Temp%\_tc\file.txt in plugin? how referer _tc?
Last edited by Hurdet on 2024-11-03, 11:09 UTC, edited 2 times in total.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Dalai »

Hurdet wrote: 2024-11-03, 09:25 UTCHow you create %Temp%\_tc\file.txt in plugin? how referer _tc?
TC passes the path to the local file when calling the plugin interface function FsGetFile of a WFX plugin. The plugin can then write to that file. When viewing a file within a WFX plugin via F3 TC passes a path somewhere within %TEMP%\_tc [1], and it passes the opposite panel's path when copying a file from a plugin via F5.

[1] Note that this path is not fixed. It can change when TC needs multiple temporary directories simultaneously. I've seen %TEMP%\_tc_ and similar directory names.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Hurdet
Power Member
Power Member
Posts: 704
Joined: 2003-05-10, 18:02 UTC

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Hurdet »

How wait lister close after copydata call?
do it work also for you?
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Dalai »

I haven't bothered implementing opening internal Lister as I requested here. It's too much effort without some cooporation from TC's side.

You can wait for a window to close if you know its handle. Getting that handle is probably the hard part since Lister plugins might change the Lister window's title.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Hurdet
Power Member
Power Member
Posts: 704
Joined: 2003-05-10, 18:02 UTC

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Hurdet »

Dalai wrote: 2024-11-03, 11:27 UTC I haven't bothered implementing opening internal Lister as I requested here. It's too much effort without some cooporation from TC's side.
But you now try to pass 19781 in dwData and "cm_list C:\Windows\Temp\_tc\vds.Stopped" in lpData in you copydata code?
It work fine for me and it is simple.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Dalai »

Hurdet wrote: 2024-11-03, 11:38 UTCBut you now try to pass 19781 in dwData and "cm_list C:\Windows\Temp\_tc\vds.Stopped" in lpData in you copydata code?
What's this magic number 19781?
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Hurdet
Power Member
Power Member
Posts: 704
Joined: 2003-05-10, 18:02 UTC

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Hurdet »

I write before:
$dwData = Asc("E") + 256 * Asc("M")
EM
I not know if is bug that EM work and CM not with cm_list.
User avatar
Dalai
Power Member
Power Member
Posts: 9943
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Call Lister (send cm_List) with parameter - possible?

Post by *Dalai »

Ah, I see. I tried it and it works. Unfortunately it requires TC 9.0 or higher, as can be read in this thread Collected infos about WM_COPYDATA, WM_USER+50 and WM_USER+51 in TC. The plugin interface version is exactly the same, so a plugin is pretty clueless about whether or not the running TC supports this kind of command. And I don't want to check the running TC's version either. But I would need to know if the running TC supports that to be able to disable/hide the items referring to internal Lister calls. It comes back to what I said before: it's not so easy without some coorporation or indication from TC.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Post Reply