tiredodftry Posted April 25, 2013 Share Posted April 25, 2013 I have a script I wrote for monitoring and it works well except for continuing after a form is closed. Most likely I am missing something simple, but what I want it to do is as follows. 1) Watch for a field change 2) Display a form with the changes 3) When the form is closed start at step 1 again Here is a very simplified script which shows the same issue as I am having. What I want the code below to do is. 1) Show the message box stating 'This should be displayed' 2) Show a form with a 'Close' button 3) When the form is closed (with the close button), start at step 1 again (show message, show form, etc) Should this work? If not, how can I get the expected results above? Thanks, Randy #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> While 1 MsgBox(0, "Test", "This should be displayed") showGUI() WEnd Func showGUI() #Region ### START Koda GUI section ### $Form1 = GUICreate("Any Form", 425, 176, 100, 177) $btnClose = GUICtrlCreateButton("Close", 160, 130, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $btnClose GUIDelete($form1) EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 25, 2013 Moderators Share Posted April 25, 2013 (edited) Your script is doing just what you told it to, delete the GUI and end. If you wanted to loop back to the start, you would have to put the first few lines in a function, like this (terribly inefficient, btw): #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> _Main() Func _Main() While 1 MsgBox(0, "Test", "This should be displayed") showGUI() WEnd EndFunc Func showGUI() #Region ### START Koda GUI section ### $Form1 = GUICreate("Any Form", 425, 176, 100, 177) $btnClose = GUICtrlCreateButton("Close", 160, 130, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $btnClose GUIDelete($form1) _Main() EndSwitch WEnd EndFunc Edit: Or do it Melba's way I've never done it that way before. Still, rather than deleting and recreating your GUI over and over again, you might consider a child just to perform one step, and then destroy that one. Edited April 25, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 25, 2013 Moderators Share Posted April 25, 2013 tiredodftry,Add a Return line after the GUIDelete line so that the function ends and you get back to the loop. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tiredodftry Posted April 25, 2013 Author Share Posted April 25, 2013 I figured it would be something simple. The 'Return' worked like charm. Thanks Melba Link to comment Share on other sites More sharing options...
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