Welcome!

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

SignUp Now!

Example of using TASKDIALOG Custom Buttons for menu item selection

Aug
1,917
68
1527114609331.png


Code:
@setlocal
@echo off
set title="Custom Button Dialog Box"
set instruction="Here's What To Do:"
set text=Check one of the following buttons:
set ac="Open"
set ad="Click on a button to select it"
set ae="Close"
set b1="IP address(es) of local computer."
set b2="Index of the current adapter"
set b3="Number of adapters in the system"
set b4="Display the IP Address for each adapter"
set b5="Exit"

set CustomButtons=/B%b1 /B%b2 /B%b3 /B%b4 /B%b5

taskdialog /A%ad /AC%ac /AE%ae %CustomButtons /I /L %title %instruction %text

switch %_taskdialog_button
case 1000
  echo You pressed the %b1 button
  echo The IP address(es) of local computer are %_ip
case 1001
  echo You pressed the %b2 button
  echo The index of the current adapter is %_ipadapter
case 1002
  echo You pressed the %b3 button
  echo There are %_ipadapters adapters in the system
case 1003
  echo You pressed the %b4 button
  echo Adapter # IP Address
  do kount=0 to %@dec[%_ipadapters]
    echo %@formatn[9.0,%kount] %@ipaddressn[%kount]
  enddo
case 1004
  echo You pressed the %b5 button
endswitch
endlocal

Joe
 
Take note of requirements when putting a second line in a button.

Some things are not clear in the help file.


(@Charles Dye helped me with that problem)

Joe
 
To keep the TaskDialog on the screen, put the process in a loop;
Code:
do forever
  taskdialog /A%ad /AC%ac /AE%ae %CustomButtons /I /L %title %instruction %text

  switch %_taskdialog_button
  case 1000
    echo You pressed the %b1 button
    echo The IP address(es) of local computer are %_ip
  case 1001
    echo You pressed the %b2 button
    echo The index of the current adapter is %_ipadapter
  case 1002
    echo You pressed the %b3 button
    echo There are %_ipadapters adapters in the system
  case 1003
    echo You pressed the %b4 button
    echo Adapter # IP Address
    do kount=0 to %@dec[%_ipadapters]
      echo %@formatn[9.0,%kount] %@ipaddressn[%kount]
    enddo
  case 1004
    echo You pressed the %b5 button
    leave
  endswitch
enddo

Add leave to the case 1004 statement to exit the TaskDialog.

Joe
 

Similar threads

Back
Top