Jump to content

Recommended Posts

Posted

I created a GUI with a selection of 3 check boxes that if checked should run each of those selected then move on in the script. I pulled the GUI out of my main script and including it. I cannot see why its not running the items I select then dropping out of the loop. I know I must be missing something small but not sure what it is. If I do not select anything it drops out of the loops but if I choose just one it will run each if statement but will not drop out of the loop. It looks like it continues in the loop for some reason. Any Pointers are appreciated since I have not been able to find the solution myself yet.

 

Thank you.

 

P.S: I just copied the #include from main script so I know there seems to be alot that are not needed for this small script.

 

Checkboxtest.au3

Posted

You need to have an ExitLoop at the end of the  Case  $OpenAppsButton if you want it to drop out of the loop.  Also I don't believe that the send key will work after ShellExecute if you don't Sleep until the process is visible.

Posted

Thank you Nine. Its working now. One strange thing left though is that after it runs through the loop if the $EpicProd is checked it removes the  changes the label on the line "$EpicProd = GUICtrlCreateCheckbox("Epic Prod", 8, 120, 70, 17) ;41,17"   It changes the words Epic Prod to Checked. Both other lines are not changed if they are checked or not checked but that one. Can't see why that one line changes but not the other two. none of them should change but this one does for some reason.

Posted

Its because you are using GuiCtrlSetData incorrectly:

If GUICtrlRead($EpicProd) = $GUI_CHECKED Then
    GUICtrlSetData($EpicChecked, 'Checked')

Should be:

If GUICtrlRead($EpicProd) = $GUI_CHECKED Then
    $EpicChecked = 'Checked'

$EpicProd = GUICtrlCreateCheckbox("Epic Prod", 8, 120, 70, 17)

$EpicProd has a Gui Ctrl Id of 4

When you used $EpicChecked = GuiCtrlRead($EpicProd), this returned a number:

  • 1 = checked
  • 4 = unchecked

When you used GuiCtrlSetData you were changing the name of Gui Ctrl Id 4 i.e. $EpicProd not $EpicChecked.

Hope that made sense.

Noticed a few other things which could be improved on, here is how I would have written your code:

#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>

Global $sOMPlusChecked, $sEpicChecked, $sPuttyLWSChecked
Global $aTaskbarPos = WinGetPos("[CLASS:Shell_TrayWnd]", "")

Global $hWnd = GUICreate("Which of these programs do you need opened?:", 450, 250, @DesktopWidth - 450 - 4, @DesktopHeight - 250 - $aTaskbarPos[3] - 4, Default, $WS_EX_TOPMOST)
Global $idOMPlusAdmin = GUICtrlCreateCheckbox("OM Plus Admin", 8, 100, 89, 17)
Global $idEpicProd = GUICtrlCreateCheckbox("Epic Prod", 8, 120, 70, 17) ;41,17
Global $idPuttyLWS = GUICtrlCreateCheckbox("Putty LWS", 8, 140, 70, 17) ;41, 17
    GUICtrlCreateLabel("If either EPIC or Chronicles is open but not logged in just log into both at this time.", 8, 30)
    GUICtrlCreateLabel("CHECKMARK any that are not open then hit continue.", 8, 50)
Global $idOpenAppsButton = GUICtrlCreateButton("Continue", 8, 180, 75, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idOpenAppsButton
            $sOMPlusChecked = GUICtrlRead($idOMPlusAdmin) = $GUI_CHECKED ? "Checked" : "Unchecked"
            If $sOMPlusChecked = "Checked" Then
                ShellExecute(@LocalAppDataDir & "\Microsoft\Windows\Start Menu\Programs\Plus Technologies OM Plus DM\Control Panel.lnk")
                Sleep(2000)
            EndIf
            $sEpicChecked = GUICtrlRead($idEpicProd) = $GUI_CHECKED ? "Checked" : "Unchecked"
            If $sEpicChecked = "Checked" Then
                ShellExecute(@LocalAppDataDir & "\Microsoft\Windows\Start Menu\Programs\Epic\Hyperspace PROD.lnk")
                Sleep(2000)
            EndIf
            $sPuttyLWSChecked = GUICtrlRead($idPuttyLWS) = $GUI_CHECKED ? "Checked" : "Unchecked"
            If $sPuttyLWSChecked = "Checked" Then
                ShellExecute(@LocalAppDataDir & "\Microsoft\Windows\Start Menu\Programs\Epic\Putty_for_Epic.lnk")
                ;~ You should change Send to ControlSend (See Help File for more info)
                Send("{TAB 4} " & " {DOWN 12} " & " {ENTER}")
                ;~ You should have a timeout on WinWaitActive otherwise the script will just be in a paused state until either you close the script or the window becomes active.
                WinWaitActive("You are connected to Epic PROD Environment - \\Remote", "", 5)
                ;~ You should change Send to ControlSend (See Help File for more info)
                Send("2" & " {ENTER} ")
                Sleep(2000)
            EndIf
            ExitLoop
    EndSwitch
WEnd
GUIDelete($hWnd)
MsgBox(BitOR($MB_OK, $MB_SYSTEMMODAL, $MB_TOPMOST), "Hit OK when all are ready.", "Hit Ok once all 3 are logged into the main menu's and ready for input.")

 

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
  • Recently Browsing   0 members

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