Jump to content
Sign in to follow this  
thebman

In over my head with Radio Buttons

Recommended Posts

thebman

I already made 4 individual scripts that I run depending on what I need to do after I image a computer. [New Builds] - just run the fixes (all the items listed on the second tab), no data transferred; on a [Refresh] run the fixes and then transfer data from an externally attached HDD. I tried to make a GUI to chose between the four. Where do I put my existing (((working))) code from my other scripts.

Right now I'm trying to code the following:

(1)User clicks a radio button for what ever function he will be doing

(2)Inputs USB drive letter or letters

(3)Hits OK button and the reset of the script will run the fixes/installs (or) fixes/installs & data transfer.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\fs_kzrvh0\Desktop\hp_app_rev2.kxf
$Form1 = GUICreate("Post Build Tool", 261, 446, 228, 133)
GUISetIcon(@SystemDir & "\shell32.dll", 68)

$Tabs = GUICtrlCreateTab(2, 0, 256, 405)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
; Tab 1 - Tool Tab
$TabSheet1 = GUICtrlCreateTabItem("Tool")
$info_line1 = GUICtrlCreateLabel("You must be logged in as the user", 22, 33, 172, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$info_line2 = GUICtrlCreateLabel("to use this tool !", 22, 49, 82, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$info_line3 = GUICtrlCreateLabel("Currently logged in as :   ", 22, 73, 127, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$c_user_label = GUICtrlCreateLabel(@UserName, 12, 90, 233, 18, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0xFF0000)
; Post Build Group
$Task_box = GUICtrlCreateGroup("Post Build Process", 14, 113, 233, 177)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$etnet_new = GUICtrlCreateRadio("ETNet [ New Build ]", 30, 137, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$ecd_new = GUICtrlCreateRadio("ECD [ New Build ]", 30, 177, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$etnet_rfsh = GUICtrlCreateRadio("ETNet [ Refresh ]", 30, 217, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$ecd_rfsh = GUICtrlCreateRadio("ECD [ Refresh ]", 30, 257, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
GUICtrlCreateGroup("", -99, -99, 1, 1)
; USB drive letters group
$Drive_box = GUICtrlCreateGroup("USB Drive's", 12, 289, 233, 105)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$usb_label_1 = GUICtrlCreateLabel("Thumb Drive Letter: ", 30, 321, 167, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$usb_label_2 = GUICtrlCreateLabel("External Drive Letter: ", 30, 353, 167, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$usb_in_1 = GUICtrlCreateInput("", 188, 319, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
$usb_in_2 = GUICtrlCreateInput("", 188, 351, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
GUICtrlSetState($usb_in_2,$GUI_DISABLE)   ; the label is in disable state
GUICtrlSetBkColor($usb_in_2, 0xC0C0C0)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;Tab 2 - Apps Tab
$TabSheet2 = GUICtrlCreateTabItem("Apps")
$Label1 = GUICtrlCreateLabel("If you only need to install one piece of software,", 18, 33, 235, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$Label2 = GUICtrlCreateLabel("please select the appropriate box and hit OK.", 18, 49, 227, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$telnet_button = GUICtrlCreateRadio("Add Hummingbird EDS_TELNET Link", 18, 88, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$iss_button = GUICtrlCreateRadio("Run ISScript fix", 18, 118, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$msg_button = GUICtrlCreateRadio("Install Windows Messenger", 18, 148, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$access_button = GUICtrlCreateRadio("Repair Access 2k3 Runtime", 18, 178, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$flash_button = GUICtrlCreateRadio("Install Flash Player", 18, 238, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$java_button = GUICtrlCreateRadio("Install Java 1.6", 18, 208, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$sdat_button = GUICtrlCreateRadio("Install SuperDAT file", 18, 268, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$matlab_button = GUICtrlCreateRadio("Update MATLAB License(s)", 18, 298, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$radia_button = GUICtrlCreateRadio("Force Radia to Start", 18, 328, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$dns_button = GUICtrlCreateRadio("Repair DNS suffix List", 18, 358, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$apps_drive_label = GUICtrlCreateLabel("Thumb Drive Letter: ", 100, 380, 126, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$apps_drive = GUICtrlCreateInput("", 218, 378, 33, 22, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlSetState($apps_drive,$GUI_DISABLE)   ; the label is in disable state
GUICtrlSetBkColor($apps_drive, 0xC0C0C0)
GUICtrlCreateTabItem("")

; Buttons at the bottom of application
$OK_button = GUICtrlCreateButton("&OK", 2, 416, 75, 25, 0)
$cancel_button = GUICtrlCreateButton("&Cancel", 92, 416, 75, 25, 0)
$help_button = GUICtrlCreateButton("&Help", 182, 416, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
            ExitLoop
    Case $Cancel_button
            ExitLoop
    Case $etnet_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)
            
    Case $ecd_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)

EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Valuater

You can use your existing script info in two ways

1 use it as an Include and called by a function

2 Use it as a function by pasting the code

example of #2

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\fs_kzrvh0\Desktop\hp_app_rev2.kxf
$Form1 = GUICreate("Post Build Tool", 261, 446, 228, 133)
GUISetIcon(@SystemDir & "\shell32.dll", 68)

$Tabs = GUICtrlCreateTab(2, 0, 256, 405)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
; Tab 1 - Tool Tab
$TabSheet1 = GUICtrlCreateTabItem("Tool")
$info_line1 = GUICtrlCreateLabel("You must be logged in as the user", 22, 33, 172, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$info_line2 = GUICtrlCreateLabel("to use this tool !", 22, 49, 82, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$info_line3 = GUICtrlCreateLabel("Currently logged in as :   ", 22, 73, 127, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$c_user_label = GUICtrlCreateLabel(@UserName, 12, 90, 233, 18, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0xFF0000)
; Post Build Group
$Task_box = GUICtrlCreateGroup("Post Build Process", 14, 113, 233, 177)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$etnet_new = GUICtrlCreateRadio("ETNet [ New Build ]", 30, 137, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$ecd_new = GUICtrlCreateRadio("ECD [ New Build ]", 30, 177, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$etnet_rfsh = GUICtrlCreateRadio("ETNet [ Refresh ]", 30, 217, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$ecd_rfsh = GUICtrlCreateRadio("ECD [ Refresh ]", 30, 257, 177, 17)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
GUICtrlCreateGroup("", -99, -99, 1, 1)
; USB drive letters group
$Drive_box = GUICtrlCreateGroup("USB Drive's", 12, 289, 233, 105)
GUICtrlSetFont(-1, 8, 800, 2, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$usb_label_1 = GUICtrlCreateLabel("Thumb Drive Letter: ", 30, 321, 167, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$usb_label_2 = GUICtrlCreateLabel("External Drive Letter: ", 30, 353, 167, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Lucida Fax")
$usb_in_1 = GUICtrlCreateInput("", 188, 319, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
$usb_in_2 = GUICtrlCreateInput("", 188, 351, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
GUICtrlSetState($usb_in_2,$GUI_DISABLE)   ; the label is in disable state
GUICtrlSetBkColor($usb_in_2, 0xC0C0C0)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;Tab 2 - Apps Tab
$TabSheet2 = GUICtrlCreateTabItem("Apps")
$Label1 = GUICtrlCreateLabel("If you only need to install one piece of software,", 18, 33, 235, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$Label2 = GUICtrlCreateLabel("please select the appropriate box and hit OK.", 18, 49, 227, 18)
GUICtrlSetFont(-1, 8, 400, 2, "Lucida Fax")
$telnet_button = GUICtrlCreateRadio("Add Hummingbird EDS_TELNET Link", 18, 88, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$iss_button = GUICtrlCreateRadio("Run ISScript fix", 18, 118, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$msg_button = GUICtrlCreateRadio("Install Windows Messenger", 18, 148, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$access_button = GUICtrlCreateRadio("Repair Access 2k3 Runtime", 18, 178, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$flash_button = GUICtrlCreateRadio("Install Flash Player", 18, 238, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$java_button = GUICtrlCreateRadio("Install Java 1.6", 18, 208, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$sdat_button = GUICtrlCreateRadio("Install SuperDAT file", 18, 268, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$matlab_button = GUICtrlCreateRadio("Update MATLAB License(s)", 18, 298, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$radia_button = GUICtrlCreateRadio("Force Radia to Start", 18, 328, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$dns_button = GUICtrlCreateRadio("Repair DNS suffix List", 18, 358, 233, 17)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
$apps_drive_label = GUICtrlCreateLabel("Thumb Drive Letter: ", 100, 380, 126, 20)
GUICtrlSetFont(-1, 9, 800, 0, "Lucida Fax")
GUICtrlSetColor(-1, 0x800000)
$apps_drive = GUICtrlCreateInput("", 218, 378, 33, 22, BitOR($ES_CENTER,$ES_AUTOHSCROLL), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetLimit(-1, 1)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlSetState($apps_drive,$GUI_DISABLE)   ; the label is in disable state
GUICtrlSetBkColor($apps_drive, 0xC0C0C0)
GUICtrlCreateTabItem("")

; Buttons at the bottom of application
$OK_button = GUICtrlCreateButton("&OK", 2, 416, 75, 25, 0)
$cancel_button = GUICtrlCreateButton("&Cancel", 92, 416, 75, 25, 0)
$help_button = GUICtrlCreateButton("&Help", 182, 416, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
            ExitLoop
    Case $Cancel_button
            ExitLoop
    Case $etnet_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)
            Refresh_ENET()
    Case $ecd_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)

EndSwitch
WEnd

Func Refresh_ENET()
    MsgBox(0x0,"Info", "Place your existing script here as a *Function*   ", 5)
    ; paste other code here
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
thebman

Where in the code do I make them click the OK button before the script will call my function's?

One other issue that I just thought of; what if some where to click a radio button on the first tab, but then also clicked on a radio button in the second tab? How could I make sure all radio buttons on the non active tab are unclicked?

Share this post


Link to post
Share on other sites
enaiman

Where in the code do I make them click the OK button before the script will call my function's?

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
            ExitLoop
    Case $Cancel_button
            ExitLoop
    Case $etnet_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)
            
    Case $ecd_rfsh
            GUICtrlSetState($usb_in_2,$GUI_ENABLE)   ; the label is enabled
            GUICtrlSetBkColor($usb_in_2, 0xFFFFFF)
    Case $OK_button
            ;run whatever you need here or call a function
EndSwitch
WEnd

One other issue that I just thought of; what if some where to click a radio button on the first tab, but then also clicked on a radio button in the second tab? How could I make sure all radio buttons on the non active tab are unclicked?

Do a check:

for first tab:

IF radio1 checked OR radio2 checked OR radio3 checked OR radio4 checked THEN

declare a variable like $Tab1Checked = 1 (it will be 0 if there is no radio checked)

ELSE

$Tab1Checked = 0

ENDIF

for second tab:

IF radio1 checked OR radio2 checked OR radio3 checked OR radio4 checked OR .... other radio checked ....THEN

declare a variable like $Tab2Checked = 1 (it will be 0 if there is no radio checked)

ELSE

$Tab2Checked = 0

ENDIF

then check the results:

SELECT

CASE $Tab1Checked = 0 AND $Tab2Checked = 0

;the user needs to check something ... warn them

CASE $Tab1Checked = 1 AND $Tab2Checked = 1

;the user needs to to have only 1 tab checked ... warn them

CASE ELSE ; it is exactly the correct case

;do whatever you need to do

ENDSELECT

You will have to put this in code :P


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×