Jump to content

Switch and Case Execution


Go to solution Solved by Melba23,

Recommended Posts

Hello.

I've been having an issue getting my GUI to execute a program once a button is pushed and a certain box is checked. Here's the code and i'll post the issue in more detail below.

Func GUI ()

#Region ### START Koda GUI section ### Form=C:\Users\cthomas\Desktop\User Mode Checklist.kxf
$Form1 = GUICreate("User Mode GUI", 403, 333, 415, 178)
$Title = GUICtrlCreateLabel("User Mode Settings", 34, 16, 334, 15, $SS_CENTER)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Background = GUICtrlCreateCheckbox("Have Set Background", 32, 56, 145, 17)
$DesktopIcons = GUICtrlCreateCheckbox("Have Set Desktop Icons", 32, 96, 145, 17)
$FolderOptions = GUICtrlCreateCheckbox("Have Set Folder Options", 32, 136, 145, 17)
$StartMenu = GUICtrlCreateCheckbox("Have Set Start Menu", 32, 176, 145, 17)
$OfficeBars = GUICtrlCreateCheckbox("Configured Office Toolbars", 32, 216, 145, 17)
$Printers = GUICtrlCreateCheckbox("Installed Printers", 232, 96, 137, 17)
$RDP = GUICtrlCreateCheckbox("Have Set RDP", 232, 56, 137, 17)
$ECHO = GUICtrlCreateCheckbox("Install Clinician's Desktop", 232, 136, 137, 17)
$Barracuda = GUICtrlCreateCheckbox("Install Web Filter", 232, 176, 137, 17)
$Install = GUICtrlCreateButton("Done", 64, 272, 99, 25)
$Restart = GUICtrlCreateButton("Restart", 240, 272, 99, 25)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$EchoValue = GUICtrlRead($ECHO)
$BarracudaValue = GUICtrlRead($Barracuda)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Install
            Switch ($EchoValue)
               Case $GUI_CHECKED
                  Run ("\\server\disks\Echo Upgrade 112613\9.1.2.4\Install_EchoWorkstation_912.exe")
               Case $GUI_UNCHECKED
                  MsgBox (0, "No Echo", "Clinician's Desktop will not be installed")
            EndSwitch
            Switch ($BarracudaValue)
               Case $GUI_CHECKED
                  Run ("\\server\OSCE Installers\BarracudaWSASetup.exe")
               Case $GUI_UNCHECKED
                  MsgBox (0, "No Web Filter", "Barracuda Web Filter will not be installed")
            EndSwitch

         Case $Restart
               Run ("Shutdown -r -t 01 -f")

    EndSwitch
 WEnd


EndFunc

The goal:

When clicking the "install" button it is supposed to install the Echo Workstation and the Barracuda web filter IF those boxes are checked. If they are unchecked it is supposed to prompt the user with a msgbox telling them the program(s) will not be installed.

Now, when I check the boxes and click the Install button it instead gives me the Unchecked messagebox (meaning the code does sort of work). However, if I uncheck the boxes it still gives me the message box saying the software will not be installed. To further test I added a "Case Else" line to see if it wasn't registering checks at all and it still gave me the will not be installed message.

I am assuming it is something very silly I missed, but I have looked through some samples on the forums and the help file and can't seem to pinpoint the issue. Any help would be appreciated!

Link to comment
Share on other sites

  • Moderators
  • Solution

ct253704,

You are only reading the checkbox states once immediately after the GUI is created - you need to read them as the install process begins: ;)

Case $Install
    $EchoValue = GUICtrlRead($ECHO)
    $BarracudaValue = GUICtrlRead($Barracuda)
    Switch $EchoValue
    ; [...]
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...