Information about user-defined commands em_

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
kodepr
Junior Member
Junior Member
Posts: 47
Joined: 2019-09-05, 08:13 UTC

Information about user-defined commands em_

Post by *kodepr »

Hi,

I'm going through TC help file to learn some new things.

Help mentions: "Additionally, you can define your own commands with prefix em_ via "Choose command" and then use them here."

- Not much shows up when searching the help file for "em_". Where can I find more information about userd-defined commands?
- I have no programming skills whatsoever. Is this worth looking into or is this way out of my league?
I'm currently using Total Commander Version 10.00 64bit
User avatar
Gral
Power Member
Power Member
Posts: 1609
Joined: 2005-01-26, 15:12 UTC

Re: Information about user-defined commands em_

Post by *Gral »

It's very easy.
E.g. you can build user command for run NOTEPAD.EXE and open file from cursor, so set NOTEPAD.EXE as a command and %P%N (file path+name) as a parameter resulting such a entry in USERCMD.INI

[em_notepad]
cmd=NOTEPAD.EXE
param=%P%N
Last edited by Gral on 2022-03-23, 16:56 UTC, edited 1 time in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 7012
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Information about user-defined commands em_

Post by *Horst.Epp »

An example from my usercmd.ini

Code: Select all

[em_TeraCopy]
button=c:\tools\TeraCopy\TeraCopy.exe,0
cmd=c:\tools\TeraCopy\TeraCopy.exe
menu=Copy with TeraCopy
param=Copy *"%UL" "%T" /NoClose
em_TeraCopy is the name for adding it into a button or menu
Button defines the icon
Cmd defines the tool to start
Menu is the tooltip for the button
Param contains the parameters for the tool to start
Windows 11 Home, Version 24H2 (OS Build 26100.4351)
TC 11.55 RC7 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.4 x64
kodepr
Junior Member
Junior Member
Posts: 47
Joined: 2019-09-05, 08:13 UTC

Re: Information about user-defined commands em_

Post by *kodepr »

I see, thanks.

2 questions:
  1. Created your Notepad example with Change start menu. Then %P%N doesn't work for me after selecting a .txt file and then selecting the Notepad command in the start menu. Only works if I change parameters to %P%S. Or should I select files/run command in a different way if parameters are set to %P%N?
  2. Probably my fault, but from the Notepad example I don't see the advantage of user-defined commands. I already have buttons in Total Commander that have the same functionality. Button command is path to an .exe and parameters is set to %P%S. Same functionality without the need for a user-defined command. What am I missing to understand benefits of userd-defined commands?
Will look into TeraCopy (never heard of it before) and your TeraCopy example asap.
I'm currently using Total Commander Version 10.00 64bit
User avatar
Horst.Epp
Power Member
Power Member
Posts: 7012
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Information about user-defined commands em_

Post by *Horst.Epp »

You can add cm_ and em_commands in View mode settings
but not your simple button definitions.
Also you can chain such commands for more complex jobs.

%P%N is normal for single selected files and definitely works in buttons and commands.
Read the button help what %S is for
Windows 11 Home, Version 24H2 (OS Build 26100.4351)
TC 11.55 RC7 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.4 x64
User avatar
tuska
Power Member
Power Member
Posts: 4113
Joined: 2007-05-21, 12:17 UTC

Re: Information about user-defined commands em_

Post by *tuska »

Hi,
em_commands are required, for example, to create/re-define shortcuts.
(Configuration -> Options... -> Misc. -> Redefine hotkeys (Keyboard remapping) ...).

Example (shortcut Shift+Y):
It is saved in the file: wincmd.ini in the [Shortcuts] section:
S+Y=em_CD_D-Daten_I-Daten

Furthermore, several commands can be used in one button, including em_commands - example:
3 em_commands for 1 button.

Button with command:
cm_50Percent,em_CD_D-Daten_I-Daten
------------------------------------------------
em_command:em_CD_D-Daten_I-Daten
Command: cm_FocusLeft,cm_SrcActivateTab1,em_D-Daten,cm_TrgActivateTab1,em_I-Daten,cm_FocusLeft,cm_RereadSource,cm_rereadsource 1

em_command:em_D-Daten
Command: cd D:\Daten

em_command:em_I-Daten
Command: command: cd I:\Daten

Important:
No spaces are allowed in the name of em_commands!


This has the effect that after clicking on the button with command: cm_50Percent,em_CD_D-Daten_I-Daten
- the view is set to 50:50, if necessary
- In the left window, the directory D:\Daten\*.* is set for the first tab and this tab is activated
- In the right-hand window, the directory I:\Daten\*.* is set for the first tab (window inactive).
- updates of the view are carried out
Instead of clicking on the button, the shortcut Shift+Y can also be used (if defined - please see above).

The description of the individual commands, e.g. cm_SrcActivateTab1 can be viewed either in the CommandBrowser
(enter cm_CommandBrowser in the command line of Total Commander and press ENTER, then enter the command in the "Filter" field)
or you can search/filter for the term cm_RereadSource in the file HISTORY.TXT.

One can probably list other advantages of em_commands...
User avatar
Gral
Power Member
Power Member
Posts: 1609
Joined: 2005-01-26, 15:12 UTC

Re: Information about user-defined commands em_

Post by *Gral »

kodepr wrote: 2022-03-23, 17:28 UTC ...
Probably my fault, but from the Notepad example I don't see the advantage of user-defined commands. I already have buttons in Total Commander that have the same functionality. Button command is path to an .exe and parameters is set to %P%S. Same functionality without the need for a user-defined command. What am I missing to understand benefits of userd-defined commands?
It's just example, as simple as possible to learn how build user command. Benefit in any case is possibility to use user command in menus.
You can of course make more complex user command.
User avatar
tuska
Power Member
Power Member
Posts: 4113
Joined: 2007-05-21, 12:17 UTC

Re: Information about user-defined commands em_

Post by *tuska »

Here is another small(!) example with step-by-step instructions.
User avatar
petermad
Power Member
Power Member
Posts: 16115
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Information about user-defined commands em_

Post by *petermad »

2kodepr
For inspiration you could try my Extended Menus (see signature) - there is more than 550 em_commands in use.
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply