Page 1 of 1
Add an executable or internal command for SendMessage / external scripting
Posted: 2023-05-15, 12:56 UTC
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
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-05-15, 20:22 UTC
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.
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 09:59 UTC
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 2
MVV ?
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 13:39 UTC
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 2
MVV ?
He was noted here in several topics 3 days ago.
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 15:56 UTC
by Gral
2 Stefan2
External program I propose in this thread -
viewtopic.php?t=78879 - would be useful here as well
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 16:47 UTC
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.
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 16:54 UTC
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.
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 17:11 UTC
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}).
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 17:30 UTC
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
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 17:36 UTC
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
Right, the same idea
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

)
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 17:39 UTC
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

, that are just quick&dirty examples
This thread is about an TC-supporting tool , not an "how-to-do" question
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 17:48 UTC
by Fla$her
Stefan2 wrote: 2023-06-01, 17:36 UTC
Right, the same idea
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

, that are just quick&dirty examples
Where do I focus too much? This answer was not dedicated to you and didn't concern your request at all.
Re: Add an executable or internal command for SendMessage / external scripting
Posted: 2023-06-01, 22:10 UTC
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.