Sign in to follow this  
Followers 0
Champak

Cant get exit loop with button to work

6 posts in this topic




#2 ·  Posted (edited)

I'm trying to figure out why you are not using a while loop instead. You say the loop could be anywhere between 1 and 5000 iterations. This loop will most likely time out before you get chance to interact with your GUI, so unless you are superman, nothing is likely to happen at that speed.

I also don't know what ' ; A bunch of code ' is doing in that first loop.

Edited by czardas

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Right.  Or even a Do loop.

Do
    $msg = GUIGetMsg()
   Select
    Case $msg = $LOAD_SCREEN
      SomeFunc()
   EndSelect
Until $msg = $GUI_EVENT_CLOSE
 
Edited by MilesAhead

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

 @MilesAhead, I guess I could go that route. I didn't know the For loop is the only one apparently that I cant interrupt with a gui button press. I guess I'll put an Or statement on the Until so it can exit upon the count being reached or the button being pressed. thanks.

Edited by Champak

Share this post


Link to post
Share on other sites

You can't interrupt it because it's over and out of the loop in a blink of an eye

Share this post


Link to post
Share on other sites

Why not use eventmode ?

#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
Global $stop = 0

GUICreate("My GUI") 
$label = GUICtrlCreateLabel("", 10, 30, 50, 20)
$btn = GUICtrlCreateButton("stop", 10, 50, 50, 20)
GUICtrlSetOnEvent(-1, "_stop")
GUISetState()  

For $i = 1 to 1000
  If $stop Then Exitloop
  GuiCtrlSetData($label, $i)
  Sleep(300)
Next
Msgbox(0,"", "stopped")

Func _stop()
  $stop = 1
EndFunc

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