Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

/= type dialog box for any batch files?

Oct
31
0
Any trick I'm missing to display a dialog box to query for input of multiple parameters in one interface? I'd like to be able to pop up a dialog box for a script similar to any command's /= dialog box to guide the user on the needed parameters. I know I could do them one at a time but that gets a tad tedious if you have 5 or 6 you need to collect data for.
 
You will have to use an external Dialog to input various data items all at once.

I have used the Microsoft HTML Application Host to provide GUIs for console .btms

Another 3rd party solution is DialogLib which can provide GUIs for console .btms

1682420740054.png


For DialogLib, you create a VBScript .vbs file, with code to create the dialog;
Code:
' Create main DialogLib object

Set Dialog = wscript.CreateObject("DialogLib.Dialog")
Dialog.SetTitle "DialogLib demonstration"
Dialog.SetIcon "Icon.ico"
Dialog.SetSize 320, 380


' Add label

Set CredentialsLabel = Dialog.AddLabel
CredentialsLabel.SetPosition 10, 10
CredentialsLabel.SetSize 200, 30
CredentialsLabel.SetText "User credentials:"
CredentialsLabel.SetTextSize 14
CredentialsLabel.Show


' Add username entry to the dialog

Set UsernameLabel = Dialog.AddLabel
UsernameLabel.SetPosition 20, 42
UsernameLabel.SetSize 60, 20
UsernameLabel.SetText "Username:"
UsernameLabel.Show

Set UsernameTextbox = Dialog.AddTextBox
UsernameTextbox.SetPosition 85, 42
UsernameTextbox.SetSize 200, 20
' UsernameTextbox.SetText "Jenny"
UsernameTextbox.Show



' Add password entry to the dialog

Set PasswordLabel = Dialog.AddLabel
PasswordLabel.SetPosition 20, 72
PasswordLabel.SetSize 60, 20
PasswordLabel.SetText "Password:"
PasswordLabel.Show

Set PasswordTextbox = Dialog.AddTextBox
PasswordTextbox.SetPosition 85, 70
PasswordTextbox.SetSize 200, 20
PasswordTextbox.SetPass "*"
PasswordTextbox.Show


' Add label

Set FavoriteCarLabel = Dialog.AddLabel
FavoriteCarLabel.SetPosition 10, 95
FavoriteCarLabel.SetSize 200, 30
FavoriteCarLabel.SetText "My favorite car:"
FavoriteCarLabel.SetTextSize 14
FavoriteCarLabel.Show


' Add make listbox to the dialog

Set MakeLabel = Dialog.AddLabel
MakeLabel.SetPosition 20, 132
MakeLabel.SetSize 60, 20
MakeLabel.SetText "Make:"
MakeLabel.Show

Set MakeListbox = Dialog.AddListbox
MakeListbox.SetPosition 85, 130
MakeListbox.SetSize 200, 50
MakeListbox.AddElement "BMW"
MakeListbox.AddElement "Cadillac"
MakeListbox.AddElement "Ford"
MakeListbox.AddElement "Mercedes"
MakeListbox.AddElement "Volkswagen"
' MakeListbox.SetSelected 3
MakeListbox.Show


' Add model textbox to the dialog

Set ModelLabel = Dialog.AddLabel
ModelLabel.SetPosition 20, 182
ModelLabel.SetSize 60, 20
ModelLabel.SetText "Model:"
ModelLabel.Show

Set ModelTextbox = Dialog.AddTextBox
ModelTextbox.SetPosition 85, 180
ModelTextbox.SetSize 200, 20
ModelTextbox.Show

' Add Color combobox to the dialog

Set ColorLabel = Dialog.AddLabel
ColorLabel.SetPosition 20, 212
ColorLabel.SetSize 60, 20
ColorLabel.SetText "Color:"
ColorLabel.Show

Set ColorCombobox = Dialog.AddCombobox
ColorCombobox.SetPosition 85, 210
ColorCombobox.SetSize 200, 20
ColorCombobox.AddElement "Black"
ColorCombobox.AddElement "White"
ColorCombobox.AddElement "Blue"
ColorCombobox.AddElement "Green"
ColorCombobox.AddElement "Red"
' ColorCombobox.SetSelected 3
ColorCombobox.Show



' Add 4WD checkbox to the dialog

Set FWDLabel = Dialog.AddLabel
FWDLabel.SetPosition 20, 242
FWDLabel.SetSize 60, 20
FWDLabel.SetText "4WD:"
FWDLabel.Show

Set FWDCheckbox = Dialog.AddCheckbox
FWDCheckbox.SetPosition 85, 238
' FWDCheckbox.SetState True
FWDCheckbox.Show



' Add date to the dialog

Set BuildDateLabel = Dialog.AddLabel
BuildDateLabel.SetPosition 20, 267
BuildDateLabel.SetSize 60, 20
BuildDateLabel.SetText "Build date:"
BuildDateLabel.Show

Set BuildDate = Dialog.AddDatepicker
BuildDate.SetPosition 85, 265
BuildDate.SetSize 200, 200
BuildDate.Show


' Add OK and Cancel buttons to the dialog

Set ButtonOK = Dialog.AddButton
ButtonOK.SetPosition 75, 300
ButtonOK.SetSize 70, 20
ButtonOK.SetName "OK"
ButtonOK.Show

Set ButtonCancel = Dialog.AddButton
ButtonCancel.SetPosition 155, 300
ButtonCancel.SetSize 70, 20
ButtonCancel.SetName "Cancel"
ButtonCancel.Show


' Display the dialog and wait until it closes

Dialog.Show


' Check if the OK button was clicked
If Dialog.ButtonClicked = "OK" then MsgBox "You clicked the OK button, so here are the dialog values:" & vbnewline & vbnewline & _
                                           "Username: " & vbtab & UsernameTextbox.GetText & vbnewline & _
                                           "Password: " & vbtab & PasswordTextbox.GetText & vbnewline & _
                                           "Make: " & vbtab & vbtab & MakeListbox.GetSelected & vbnewline & _
                                           "Model: " & vbtab & vbtab & ModelTextbox.GetText & vbnewline & _
                                           "Color: " & vbtab & vbtab & ColorCombobox.GetSelected & vbnewline & _
                                           "4WD: " & vbtab & vbtab & FWDCheckbox.GetState & vbnewline & _
                                            "Build date:" & vbtab & BuildDate.GetDate




' Destroy the object

Set Dialog = Nothing
Pass the Dialog results back to your .BTM via a file or other means.

As the VB.Net source code for DialogLib is available for download, you can modify it to your own requirements.

Dialogs can also be created with PowerShell, LUA, etc.,
but I am used to VBScript/VB.Net,
so I stick with what I know.

Joe
 
Back
Top
[FOX] Ultimate Translator
Translate