A button that prompts user for input then passes it as a parameter to a command

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
risk
Junior Member
Junior Member
Posts: 85
Joined: 2007-07-30, 03:18 UTC

A button that prompts user for input then passes it as a parameter to a command

Post by *risk »

I am trying to create a button that will use a command line tool to compress an image file. The tool takes filename and compression level as parameters. TC can pass the file name but how do I prompt the user for compression level and pass that too?
NotNull
Senior Member
Senior Member
Posts: 269
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: A button that prompts user for input then passes it as a parameter to a command

Post by *NotNull »

Maybe Total Commander has built-in ways to accomplish this, but this should work:
When started, enter your level and press ENTER.

It should show you the command that would be executed.
Change parameters and paths to match your situation.

Code: Select all

TOTALCMD#BAR#DATA
C:\Windows\System32\cmd.exe
/k set /p LEVEL=Input level ..  & call echo "c:\path to\your program.exe" -file %P%N -level %%LEVEL%% -otheroptions
c:\path to\your program.exe


-1
If the command that is shown looks OK, replace "echo" with "start "" " and replace /k with /c.
(This is largely untested, so I hope I didn't make too many errors ....)



You can also use a ? as the first parameter in your button.
That lets you review and edit the complete command.
User avatar
Dalai
Power Member
Power Member
Posts: 9388
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: A button that prompts user for input then passes it as a parameter to a command

Post by *Dalai »

In the TC button, just add a question mark as first character in the Parameters field. This will tell TC to show a confirmation dialog for the parameters before launching the command.

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
Stefan2
Power Member
Power Member
Posts: 4155
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: A button that prompts user for input then passes it as a parameter to a command

Post by *Stefan2 »

risk wrote: 2020-04-22, 21:44 UTC I am trying to create a button that will use a command line tool to compress an image file.

>> how do I prompt the user for compression level and pass that too?

Also another option is to use MVVs' AskParam
http://totalcmd.net/plugring/askparam.html
Allows entering command line parameters in GUI dialog.
Entered parameters may be inserted into command line of process to be started in any order and ammount.
You can set dialog title, prompt text and set of suggested strings for drop-down list.


Or call an VBS or AHK script from the button and use the scripts InputBox function to ask the user.



 
Post Reply