Sign in to follow this  
Followers 0
tiredodftry

Script GUI loop problem

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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._______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

 

Share this post


Link to post
Share on other sites

I figured it would be something simple. The 'Return' worked like charm. Thanks Melba

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  
Followers 0