Add an executable or internal command for SendMessage / external scripting

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Add an executable or internal command for SendMessage / external scripting

Post by *Stefan2 »

Hello Christian, could you perhaps add yourself a small executable
or an internal command to the TOTALCMD.EXE
for to execute all that "WM_USER+50" and CM_ plus EM_ commands from an external scripting tool?


In combination with an new system variable like %Commander_Return%
set by TC and filled with the returned value of the executed command.


Using SendMessage is fine, but often to much explanation and additional tools and script sharing needed.



Something like:

Code: Select all

@ECHO OFF
totalcmd.exe /E=U "1000"  ;;; get active panel

If %Commander_Return% = 1 Then set MyCommand=9 (leftpath) Else set MyCommand=10 (rightpath)
totalcmd.exe /E "CD %MyCommand%"

totalcmd.exe /E "CM_GOTOFIRSTENTRY 0"
totalcmd.exe /E "cm_GotoNext"
totalcmd.exe /E "em_LaunchNotepad"
totalcmd.exe /E "CD C:\Temp"
Only examples, no real usage.









Example commands as found on the forum:

New cm_ commands for navigation
viewtopic.php?p=431290#p431290

TC9: "Send WM_USER+50 with wparam" - how-to?
viewtopic.php?p=310263#p310263

 
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Fla$her »

I think calling commands from TC process is a sheer excess. It's slow and impractical. There is TCFS2 for such things.
Overquoting is evil! 👎
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Stefan2 »

Fla$her wrote: 2023-05-15, 20:22 UTC I think calling commands from TC process is a sheer excess. It's slow and impractical.
Why it's "a sheer excess" ?

See TC > Help > Command line parameters
totalcmd.exe [/o] [/n] [Drive1:\Directory1 [Drive2:\Directory2]] [/i=name.ini] [/f=ftpname.ini]

That (and many more) already works.

That's why I think we could just reuse "totalcmd.exe /E[xecute]"



Fla$her wrote: 2023-05-15, 20:22 UTC There is TCFS2 for such things.
Me think we need a tool with a more simple syntax:
TC-support-tool.exe "CM_GOTOFIRSTENTRY 0"
TC-support-tool.exe "cm_GotoNext"
TC-support-tool.exe "em_LaunchNotepad"
TC-support-tool.exe "CD C:\Temp"

How would that commands look like with TCFS2 ?

And,.... any news about 2MVV ?



 
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Fla$her »

Stefan2 wrote: 2023-06-01, 09:59 UTCThat (and many more) already works.
Running with configuration parameters and folders to open is one thing, but executing commands in separate processes is quite another.
Stefan2 wrote: 2023-06-01, 09:59 UTC"CM_GOTOFIRSTENTRY 0"
Using 0 doesn't make sense.
Stefan2 wrote: 2023-06-01, 09:59 UTC How would that commands look like with TCFS2 ?
It doesn't look like a combination of interconnected commands. But since they wrote these, then so:

Code: Select all

TCFS2.exe /ef tсm(2049) tcm(571) tem(em_LaunchNotepad) tcd(`C:\Temp`,,S)
If you need to go by in the list, then write tem(`cm_GoToFirstEntry `) instead of tcm(2049).
Stefan2 wrote: 2023-06-01, 09:59 UTC And,.... any news about 2MVV ?
He was noted here in several topics 3 days ago.
Overquoting is evil! 👎
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Gral »

2 Stefan2
External program I propose in this thread - viewtopic.php?t=78879 - would be useful here as well
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Add an executable or internal command for SendMessage / external scripting

Post by *petermad »

Stefan2 wrote: ↑Thursday 01-06-2023, 11:59:29
"CM_GOTOFIRSTENTRY 0"

Using 0 doesn't make sense.
Well it could go to [..] like Home does.
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
cpp64
Junior Member
Junior Member
Posts: 83
Joined: 2023-05-12, 16:03 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *cpp64 »

2Stefan2

Is it possible to change or set the %Commander_Return% of cmd.exe in a child process TC?
As far as I know, the only Env Variable a child process can change is the %ERRORLEVEL%.
Therefore, %Commander_Return% cannot be used in cmd.exe.
I heared that the same thing can be achieved by creating two special programs that communicate with each other,
However, cmd.exe is a program that has already been made.
Even if it were possible, I don't think it would be easy.
Last edited by cpp64 on 2023-06-01, 19:06 UTC, edited 9 times in total.
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Fla$her »

petermad wrote: 2023-06-01, 16:47 UTC Well it could go to [..] like Home does.
This would probably be more correct, given that WM_USER+50 returns the indexes of the list items starting from 0, where [..] is the first item.
Now it can be done with the chain cm_GoToFirstEntry,cm_GotoPrev, and for TCFS2 it's easier to call send({HOME}).
Overquoting is evil! 👎
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Stefan2 »

cpp64 wrote: 2023-06-01, 16:54 UTC 2stefan2

Is it possible to change or set the %Commander_Return% of cmd.exe in a child process TC?
As far as I know, the only Env Variable a child process can change is the %ERRORLEVEL%.
Therefore, %Commander_Return% cannot be used in cmd.exe.

I don't know such things for sure.


But using %ErrorLevel% would be perfectly fine me think.

Like we already used here with AHK:
SendMessage 1074, 1000, 0, , ahk_class TTOTAL_CMD
MsgBox Answer from TC, active panel (1=left, 2=right) : %ErrorLevel%
https://ghisler.ch/board/viewtopic.php?p=310263#p310263



 
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Stefan2 »

Gral wrote: 2023-06-01, 15:56 UTC 2 Stefan2
External program I propose in this thread - viewtopic.php?t=78879 - would be useful here as well

Ohhh :oops:


Right, the same idea :D

TC should provide a reliable tool to execute em + cm commands and such.
With an simple syntax (tool.exe <command>) so every user can use that,
even they on a company device who have TC but are not allowed to run AHK.exe (because AHK is to powerful and can do too many funny things ;-) )




 
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Stefan2 »

Now it can be done with the chain cm_GoToFirstEntry,cm_GotoPrev, and for TCFS2 it's easier to call send({HOME}).


Don't focus toooo much on my given examples :D   ,   that are just    quick&dirty examples :mrgreen:

This thread is about an TC-supporting tool , not an "how-to-do" question :roll:



 

 
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: Add an executable or internal command for SendMessage / external scripting

Post by *Fla$her »

Stefan2 wrote: 2023-06-01, 17:36 UTC Right, the same idea :D
You have a different idea, as we can see. For the rest, read that topic. Why would the author waste time on a tool when two have been invented for a long time, and one of which is much more developed than requested?
Stefan2 wrote: 2023-06-01, 17:39 UTC Don't focus toooo much on my given examples :D   ,   that are just    quick&dirty examples :mrgreen: 
Where do I focus too much? This answer was not dedicated to you and didn't concern your request at all.
Overquoting is evil! 👎
NotNull
Senior Member
Senior Member
Posts: 269
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: Add an executable or internal command for SendMessage / external scripting

Post by *NotNull »

For inspiration purposes: Directory Opus uses an extra executable to do this kind of stuff too:
- running internal commands (cm_... em_.. in TC) and scripts
- importing collections (Listbox in TC)
- querying active/passive panes, tabs, items in a tab,paths
- start main program with a specific layout
- and more.

Getting the syntax right can be tricky sometimes (lots of options and parameters), but the mechanism itself is quite intuitive.


DopusRT Reference for more features.
Post Reply