Clipboard parameter for button bars

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Clipboard parameter for button bars

Post by *browny »

There are loads of percent-prefixed parameters for button bar.
Should yet another one to be considered - for clipboard contents?
Most useful it might be for launching programs that are getting links from command line, but other scenarios are possible too.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Clipboard parameter for button bars

Post by *Horst.Epp »

I use the NirSoft tool Nircmd.exe for this purpose.

The following button displays a folder in TC which is read from the Clipboard.

Code: Select all

TOTALCMD#BAR#DATA
em_CDToClip

C:\Tools\Wincmd\Icons\Right-Blue.ico
CD Clipboard

0
10297
Usercmd.ini entry

Code: Select all

[em_CDToClip]
cmd=c:\tools\NirSoft\x64\nircmd.exe exec show %COMMANDER_EXE% /O /S /A /L="~$clipboard$"
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: Clipboard parameter for button bars

Post by *Fla$her »

The parameter is not quite suitable for this, because multiline text can be copied. It would be better if it were an environment variable, although it also has a length limit.
Personally, I prefer to handle the clipboard with scripts, because extra characters, including whitespace, often get there. In this case, you don't need to adjust specifically to a command or button, like the one above.
Overquoting is evil! 👎
browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Re: Clipboard parameter for button bars

Post by *browny »

Fla$her wrote: 2024-10-09, 12:45 UTC It would be better if it were an environment variable
Already was. Use help button in TC.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: Clipboard parameter for button bars

Post by *Fla$her »

browny wrote: 2024-10-09, 13:15 UTC Already was. Use help button in TC.
I've done this before. There is no word "clipboard" on the "Environment variables" page.
If there was such a variable, then there would be no point in requesting a parameter.
There is only the [X] placeholder for MRT.
Overquoting is evil! 👎
browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Re: Clipboard parameter for button bars

Post by *browny »

Adding an environment variable or pseudo-variable is not easier than a new parameter.
A true environment variable might get stale.
It would be a waste to add intermediate storage between clipboard and required parameter for a button.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: Clipboard parameter for button bars

Post by *Fla$her »

Wrong. Try to execute from deep folder a few times: cd ..\%cd%
The path changes. What does this mean? That the variable is not outdated.
The same applies to variables such as COMMANDER_OPEN after changing conditions.
Overquoting is evil! 👎
browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Re: Clipboard parameter for button bars

Post by *browny »

Examples of true environment variables: path, tmp.
%cd% is not, it is an internal TC's variable (launch cmd.exe, try your command).
Fla$her wrote: 2024-10-09, 15:54 UTC What does this mean?
Might mean, you are posting nonsense and messing up a very simple suggestion.
An intermediate variable for accessing clipboard contents is not cheaper than an additional %-parameter. Also it would be in the same help page, not elsewhere.
User avatar
white
Power Member
Power Member
Posts: 5747
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Clipboard parameter for button bars

Post by *white »

browny wrote: 2024-10-10, 08:40 UTC Examples of true environment variables: path, tmp.
%cd% is not, it is an internal TC's variable (launch cmd.exe, try your command).
%cd% is not an internal TC variable, but an internal cmd.exe variable.


Edit:
In response to post below:
browny wrote: 2024-10-10, 08:51 UTC From cmd.exe window:

Code: Select all

c:\bin\wc>cd ..\%cd%
The filename, directory name, or volume label syntax is incorrect.
Of course the command "cd ..\c:\bin\wc" results in an error.
browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Re: Clipboard parameter for button bars

Post by *browny »

From cmd.exe window:

Code: Select all

c:\bin\wc>cd ..\%cd%
The filename, directory name, or volume label syntax is incorrect.
Shall we stay on topic?

Edit. In response to the edit above.

Now try cd ..\%cd% in TC's command line input field.
Any difference in behaviour? If so, what is %cd% variable in this case?
Last edited by browny on 2024-10-11, 09:54 UTC, edited 1 time in total.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: Clipboard parameter for button bars

Post by *Fla$her »

browny wrote: 2024-10-10, 08:40 UTC Examples of true environment variables: path, tmp.
%cd% is not, it is an internal TC's variable (launch cmd.exe, try your command).
All variables are true, regardless of whether they are internal or system.
browny wrote: 2024-10-10, 08:40 UTC Might mean, you are posting nonsense and messing up a very simple suggestion.
It wasn't a question for you. Are you unable to distinguish a rhetorical question from a direct one from the context?
Rough and unfounded assessments do not interest me.
browny wrote: 2024-10-10, 08:40 UTC An intermediate variable for accessing clipboard contents is not cheaper than an additional %-parameter. Also it would be in the same help page, not elsewhere.
The help page is the last thing to think about. Implementation is much more important. I do not know how you measure the cheapness, but I pointed out the most important factor - multiline, which is excluded for a single-line parameter.
Overquoting is evil! 👎
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Clipboard parameter for button bars

Post by *ghisler(Author) »

For the next beta, I have added two new pseudo environment variables %$CLIPBOARD% and %$CLIPNAME% with the following options:
%$CLIPBOARD% Inserts up to 1023 unmodified characters from the clipboard
%$CLIPBOARD0% Like %$CLIPBOARD%, but line breaks are replaced by spaces
%$CLIPBOARD1%, %$CLIPBOARD2% Inserts line 1, line 2 etc. from the clipboard, otherwise unchanged
%$CLIPNAME% Inserts up to 1023 characters from the clipboard, replaces the characters *?:|"<> that are forbidden in file names with underscores_
%$CLIPNAME0% Like %$CLIPNAME%, but line breaks are replaced by spaces
%$CLIPNAME1%, %$CLIPNAME2% Inserts line 1, line 2 etc. from the clipboard, replaces the characters *?:|"<> that are forbidden in file names with underscores_

What do you think?
Author of Total Commander
https://www.ghisler.com
User avatar
funkymonk
Senior Member
Senior Member
Posts: 491
Joined: 2013-12-04, 09:56 UTC

Re: Clipboard parameter for button bars

Post by *funkymonk »

Sounds great! A long awaited feature...
Thank you!
browny
Senior Member
Senior Member
Posts: 359
Joined: 2007-09-10, 13:19 UTC

Re: Clipboard parameter for button bars

Post by *browny »

This should cover many more cases than were expected initially.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Clipboard parameter for button bars

Post by *Horst.Epp »

Very nice, so I can remove Nirsoft form many buttons.
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
Post Reply