bendover Posted April 6, 2017 Posted April 6, 2017 (edited) I have written a dialog which reads user selections, writes values to VBS script and exits after pushing button. Dialog needs a feature to check some values based on selections. GUI should show MsgBox if certain CheckBox is cheked and return to main dialog. The problem is that after showing MsgBox script exists instead of returning to GUI. It should return to GUI as long as "If" condition is true ($GUI_CHECKED in this example). Here's simple example: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GUIComboBox.au3> #include <Array.au3> #include <AD.au3> $Form1 = GUICreate("Form1", 391, 260, 192, 124) $Input = GUICtrlCreateInput("", 48, 112, 121, 21) $CheckBox = GUICtrlCreateCheckbox("CheckBox", 184, 112, 97, 17) $Button = GUICtrlCreateButton("Install", 144, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button $readCheckBox = GUICtrlRead ($CheckBox) $readInput = GUICtrlRead ($Input) ADCheck () ExitLoop EndSwitch WEnd Func ADCheck () If GUICtrlRead ($CheckBox) = $GUI_CHECKED Then MsgBox ($MB_SYSTEMMODAL, "VAR", "Hello") EndIf EndFunc Edited April 6, 2017 by bendover
Developers Jos Posted April 6, 2017 Developers Posted April 6, 2017 Well.. you do have ExitLoop in there so it will exit the While loop. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
bendover Posted April 6, 2017 Author Posted April 6, 2017 Yes it does because dialog I've written writes the values to VBS file and continues installation. I'd need to know how to handle GUI events and return to GUI after MsgBox is being closed.
Subz Posted April 6, 2017 Posted April 6, 2017 Just delete the Exitloop, once ADCheck has completed it will just return to the Gui
kaisies Posted April 7, 2017 Posted April 7, 2017 You could do something like this: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GUIComboBox.au3> #include <Array.au3> ;#include <AD.au3> $Form1 = GUICreate("Form1", 391, 260, 192, 124) $Input = GUICtrlCreateInput("", 48, 112, 121, 21) $CheckBox = GUICtrlCreateCheckbox("CheckBox", 184, 112, 97, 17) $Button = GUICtrlCreateButton("Install", 144, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button $readCheckBox = GUICtrlRead ($CheckBox) $readInput = GUICtrlRead ($Input) If ADCheck() Then ExitLoop EndSwitch WEnd Func ADCheck () If GUICtrlRead ($CheckBox) = $GUI_CHECKED Then Return MsgBox ($MB_SYSTEMMODAL, "VAR", "Hello") EndFunc
kylomas Posted April 7, 2017 Posted April 7, 2017 bendover, Try something like this... expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GUIComboBox.au3> #include <Array.au3> ;#include <AD.au3> $Form1 = GUICreate("Form1", 391, 260, 192, 124) $Input = GUICtrlCreateInput("", 48, 112, 121, 21) $CheckBox = GUICtrlCreateCheckbox("CheckBox", 184, 112, 97, 17) $Button = GUICtrlCreateButton("Install", 144, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button ;$readCheckBox = GUICtrlRead ($CheckBox) ; not sure what this is for $readInput = GUICtrlRead($Input) If ADCheck() Then _go_do_something_else() GUICtrlSetState($Input, $gui_focus) ; set cursor to input box EndSwitch WEnd Func ADCheck() If GUICtrlRead($CheckBox) = $GUI_CHECKED Then Return MsgBox($MB_SYSTEMMODAL, "VAR", "Hello") EndFunc ;==>ADCheck Func _go_do_something_else() MsgBox(0, '', 'Hi, I"m doing something else...', 2) EndFunc ;==>_go_do_something_else Incidentally, your original code would return you to the message loop if you had followed Jos's advice... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
bendover Posted April 7, 2017 Author Posted April 7, 2017 (edited) Thanks for your advice. I modified original code and now it works using functions. Edited April 7, 2017 by bendover
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now