Example of using TASKDIALOG for menu item selection

#1
Code:
@setlocal
@echo off
set title="Radio Button Dialog Box"
set instruction="Here's What To Do:"
set text=Check one of the following buttons:
set ad="After you have made a selection, press OK"
set ac="Open"
set ae="Close"
set r1="IP address(es) of local computer."
set r2="Index of the current adapter"
set r3="Number of adapters in the system"
set r4="Display the IP Address for each adapter"

taskdialog /A%ad /AC%ac /AE%ae /R%r1 /R%r2 /R%r3 /R%r4 OK CLOSE %title %instruction %text

switch %_taskdialog_button
case 10
  echo You pressed the OK button
case 12
  echo You pressed the CLOSE button
endswitch

switch %_taskdialog_radio
case 2000
  echo The IP address(es) of local computer are %_ip
case 2001
  echo The index of the current adapter is %_ipadapter
case 2002
  echo There are %_ipadapters adapters in the system
case 2003
  echo Adapter # IP Address
  do kount=0 to %_ipadapters
    echo %@formatn[9.0,%kount] %@ipaddressn[%kount]
  enddo
endswitch
endlocal
Joe
 

rps

Jul 6, 2008
276
4
#2
Cleaver use and presentation of several internal variables.
I will definitely use this.
Perhaps a loop is in order to re-display the menu when pressing OK; since, for now, pressing OK or CLOSE accomplishes the same thing.

I think the case 2003 should be:

Code:
case 2003

  echo Adapter # IP Address
  do kount=0 to %@dec[%_ipadapters]
    echo %@formatn[9.0,%kount] %@ipaddressn[%kount]
  enddo
which should account for the adapter index starting at 0.
 
Last edited: