How to create a custom button with argument?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
ArchyRomano
Junior Member
Junior Member
Posts: 5
Joined: 2018-02-19, 19:42 UTC

How to create a custom button with argument?

Post by *ArchyRomano »

Hi there!

I would like to create a button, that runs ConEmu64.exe, and passes the following command line into:

Code: Select all

youtube-dl.exe --all-subs --skip-download <weblink> -o "%(autonumber)s. %(title)s.%(ext)s"
But before it inserts and runs this command, he ask me for an argument value. This would be a web link that he inserts to the <weblink> parameter. For example:
1. Click button
2. Asking for an argument
3. MyLongWebLink
4.

Code: Select all

youtube-dl.exe --all-subs --skip-download MyLongWebLink -o "%(autonumber)s. %(title)s.%(ext)s"
Thanks! :)
User avatar
HerbieH
Member
Member
Posts: 145
Joined: 2003-02-11, 10:04 UTC

Post by *HerbieH »

You can put a question-mark as the first argument in the 'parameters' field in the button:

Code: Select all

?youtube-dl.exe --all-subs --skip-download <weblink> -o "%(autonumber)s. %(title)s.%(ext)s"
You will be given the choice to edit the command-line, before executing the button.

PS: There might be a more sophisticated way, that I don't know about (could include 'Autohotkey') that gives you the option to just edit the <weblink> parameter, instead of the whole command-line. :roll:
HerbieH*
-Keep on makin' music!
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can also use my AskParam tool, it is designed for asking for one or more command line arguments and passing them to a program.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

VBScript: Button ask User input InputBox execute command

Post by *Stefan2 »

Also, instead of using the original command directly in a button,
you could start a script (batch/vbs/autohotkey)
which has the ability to ask for and take user input
and then execute the original command with given parameter.


Example:

Code: Select all


'// Found at: https://ghisler.ch/board/viewtopic.php?p=338274#338274


' ''IB = InputBox(prompt[, title][, default] ,Xpos,Ypos,HelpFile location, Context in the help file) 
MyLongWebLink  = InputBox("Please enter:", "TC-Script", "www.default.tld")
  If (MyLongWebLink = "") Then WScript.Quit


' ''( chr(34) is quote sign "...", see ASCII table )
myCmd = "youtube-dl.exe --all-subs --skip-download " & MyLongWebLink
myCmd = myCmd & " -o  " &  chr(34)&"%(autonumber)s. %(title)s.%(ext)s"&chr(34)


MsgBox myCmd
REM ---------------------------
REM 
REM ---------------------------
REM youtube-dl.exe --all-subs --skip-download www.default.tld -o  "%(autonumber)s. %(title)s.%(ext)s"
REM ---------------------------
REM OK   
REM ---------------------------


' ''execute:
SET WSO = WScript.CreateObject("WScript.Shell")
' ''WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=minimize 3=maximize ...] [,bWaitTillFinish? True/defaultFalse]
'WSO.Run myCmd ,0 , True



 
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2ArchyRomano

If the order of the command line switches is of no importance you can just make a button like this:

Code: Select all

TOTALCMD#BAR#DATA
ConEmu64.exe youtube-dl.exe --all-subs  -o "%(autonumber)s. %(title)s.%(ext)s" --skip-download
?
ConEmu64.exe
YouTube-dl


-1
To make the button:
1. Mark the green text above (including TOTALCMD#BAR#DATA in the first line and -1 in the last line).
2. Copy it to the ClipBoard (Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
ArchyRomano
Junior Member
Junior Member
Posts: 5
Joined: 2018-02-19, 19:42 UTC

Post by *ArchyRomano »

petermad wrote:2ArchyRomano

If the order of the command line switches is of no importance you can just make a button like this:

Code: Select all

TOTALCMD#BAR#DATA
ConEmu64.exe youtube-dl.exe --all-subs  -o "%(autonumber)s. %(title)s.%(ext)s" --skip-download
?
ConEmu64.exe
YouTube-dl


-1
To make the button:
1. Mark the green text above (including TOTALCMD#BAR#DATA in the first line and -1 in the last line).
2. Copy it to the ClipBoard (Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".
Thanks for the reply. Ok, created the button, but what i don't know is how to define a variable(parameter), and point to that variable to insert my argument? Before the -o, there should be a variable.
Last edited by ArchyRomano on 2018-02-20, 18:49 UTC, edited 1 time in total.
ArchyRomano
Junior Member
Junior Member
Posts: 5
Joined: 2018-02-19, 19:42 UTC

Post by *ArchyRomano »

MVV wrote:You can also use my AskParam tool, it is designed for asking for one or more command line arguments and passing them to a program.
Thanks for the reply. Ok, created the button, but stuck. Here is what i got:

Code: Select all

Command: %PROG_FILES%\AskParam64.exe
Parameters: /c"Download Subtitles"  /c(1)"Yes" /c(2)"Cancel" /p(h)"Enter URL:" "%%PROG_FILES%%\ConEmu\ConEmu64.exe"
But how do i continue?
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Thanks for the reply. Ok, created the button, but what i don't know is how to define a variable(parameter), and point to that variable to insert my argument? Before the -o, there should be a variable.
That is why I asked whether the order of the parameters were significant. Anyway, because of the ? mark on line 3, when you click the button you should see a dialog that says: "Command line parameters": here you can enter your variable (<weblink>). Notice that I have moved --skip-download to the end of the command line, because I suspect that it has to be in front of <weblink>, which will be inserted at the end when you click OK in the dialog after you have written your weblink parameter - but I might be wrong, maybe weblink has to be before -o (in contrast to after --skip-download) - and then this button cannot be used. If that is the case, you can use this:

Code: Select all

TOTALCMD#BAR#DATA
ConEmu64.exe youtube-dl.exe --all-subs --skip-download
? -o "%%(autonumber)s. %%(title)s.%%(ext)s" 
ConEmu64.exe
YouTube-dl


-1
But then you will see -o "%(autonumber)s. %(title)s.%(ext)s" in the dialog box and you will have to write your variable in front of that - not so elegant. Notice the double %% - you have to use that in TC's parameter field.


I cannot test it myself, because I dont have neither ConEmu64.exe nor youtube-dl.exe
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
ArchyRomano
Junior Member
Junior Member
Posts: 5
Joined: 2018-02-19, 19:42 UTC

Post by *ArchyRomano »

But then you will see -o "%(autonumber)s. %(title)s.%(ext)s" in the dialog box and you will have to write your variable in front of that - not so elegant. Notice the double %% - you have to use that in TC's parameter field.
Thank you very much. :D Worked with the double %. :roll:
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

But how do i continue?
You have to pass your typed parameter to ConEmu64.exe, e.g.:

Code: Select all

Command: %PROG_FILES%\AskParam64.exe 
Parameters: /c"Download Subtitles" /p"Enter URL:"    "%%PROG_FILES%%\ConEmu\ConEmu64.exe"    "X:\Path\youtube-dl.exe" --all-subs --skip-download "%%1" -o "%%%%(autonumber)s. %%%%(title)s.%%%%(ext)s"
(here %%1 is first /p value, %%2 is second etc, and %%%% inserts a single % character because you have to double % for both both TC and AskParam)
ArchyRomano
Junior Member
Junior Member
Posts: 5
Joined: 2018-02-19, 19:42 UTC

Post by *ArchyRomano »

MVV wrote: You have to pass your typed parameter to ConEmu64.exe, e.g.:

Code: Select all

Command: %PROG_FILES%\AskParam64.exe 
Parameters: /c"Download Subtitles" /p"Enter URL:"    "%%PROG_FILES%%\ConEmu\ConEmu64.exe"    "X:\Path\youtube-dl.exe" --all-subs --skip-download "%%1" -o "%%%%(autonumber)s. %%%%(title)s.%%%%(ext)s"
(here %%1 is first /p value, %%2 is second etc, and %%%% inserts a single % character because you have to double % for both both TC and AskParam)
Thanks MVV! I managed to do it like this.
Post Reply