twikkistep Posted January 31, 2007 Share Posted January 31, 2007 Hi there,Don't exactly know how I can explain this in clear words, so I'll just try: I would like to get out of a do loop while being in an if statement - check the GUI_Stop line in italic ... The browser window in my form is running the "DoSomething" statement, but I want to have it stop doing that when I click the stop button ... any ideas?Thanks in advance!-- TSCODEDo$msg = GUIGetMsg() if $msg = $GUI_Location Then if $msg = $GUI_Stop Then ExitLoop Endif DoSomething Endif if $msg = $GUI_Location Then ExitLoop Endif Until $msg = $GUI_EVENT_CLOSE GUIDelete()Exit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 31, 2007 Moderators Share Posted January 31, 2007 Do $msg = GUIGetMsg() ;Whatever else Until $msg = $STOP_BUTTON Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
twikkistep Posted January 31, 2007 Author Share Posted January 31, 2007 Do $msg = GUIGetMsg() ;Whatever else Until $msg = $STOP_BUTTON Hi, Sorry, but this doesn't make sense to me right now ... my example shows the until part as well, at the bottom of the code - but I want to escape the first loop ... any ideas on that? -- TS Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 31, 2007 Moderators Share Posted January 31, 2007 Hi,Sorry, but this doesn't make sense to me right now ... my example shows the until part as well, at the bottom of the code - but I want to escape the first loop ... any ideas on that?-- TSThen your example doesn't make any sense at all. You're only showing one loop, so escaping the first loop escapes the only loop.Why don't you make a complete working example, and you'd probably get the answer you want so we don't have to chase our tails after you to get the answers we need to answer your question how only you know how you want it answered. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
twikkistep Posted February 1, 2007 Author Share Posted February 1, 2007 I agree - my example was not clear. Hereby a new one, I hope this one helps you understand my problem. It's the first time I try to work with a gui, so I'm tryiong to figure out how to break those loops within a function. CODE#include <IE.au3> #include <GUIConstants.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Tester", 700, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 680, 450) $GUI_Location = GUICtrlCreateInput("", 10, 10, 440, 20) $GUI_Button_Source = GUICtrlCreateButton("Source", 460, 10, 50, 20) $GUI_Button_Back = GUICtrlCreateButton("Back", 520, 10, 50, 20) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 580, 10, 50, 20) $GUI_Button_Save = GUICtrlCreateButton("Save", 640, 10, 50, 20) GUISetState() ;Show GUI $starturl = "www.yahoo.com" _IENavigate ($oIE, $starturl) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_Button_Source MsgBox(0, "GUI Event", "You pressed Source!") _ClickMySource() Case $msg = $GUI_Button_Back MsgBox(0, "GUI Event", "You pressed Back!") Case $msg = $GUI_Button_Stop MsgBox(0, "GUI Event", "You pressed Stop!") Case $msg = $GUI_Button_Save MsgBox(0, "GUI Event", "You pressed Save!") Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEnd Func _ClickMySource() While 1 Sleep(1000) ;how can I leave this loop when I click the any of the buttons? WEnd EndFunc Link to comment Share on other sites More sharing options...
twikkistep Posted February 5, 2007 Author Share Posted February 5, 2007 Anyone? Link to comment Share on other sites More sharing options...
therks Posted February 12, 2007 Share Posted February 12, 2007 The way that you have that setup, you can't. I'm having troubles with this myself at the moment. I tried something like this (to take advantage of your example): Opt('GUIOnEventMode', 1) Global $continueLooping = true ... GUI Construction, etc... Func _ClickMySource() While $continueLooping Sleep(1000) ;how can I leave this loop when I click the any of the buttons? WEnd EndFunc Func _Stop() $continueLooping = false EndFunc Then I tried calling the _Stop() function via a button using GUICtrlSetOnEvent, because I thought it might intercept it that way, but it doesn't. Once that function is looping inside itself, the rest of your script will not continue until it stops. The only workaround I have found is that if you actually set a HotKey to the _Stop() function, it will intercept and set the $continueLooping to false. So basically, you'll either have to use a HotKey, or you're going to have to do some rewriting of your script to accommodate for what you're trying to do. Have fun! My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
eltorro Posted February 18, 2007 Share Posted February 18, 2007 I don't know if it is a bug or not but in EventMode, the events die when a second loop is started. You can use some thing like this. It escapes the loop and triggers the button event. expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() GUICreate("Tester", 700, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 680, 450) $GUI_Location = GUICtrlCreateInput("", 10, 10, 440, 20) $GUI_Button_Source = GUICtrlCreateButton("Source", 460, 10, 50, 20) $GUI_Button_Back = GUICtrlCreateButton("Back", 520, 10, 50, 20) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 580, 10, 50, 20) $GUI_Button_Save = GUICtrlCreateButton("Save", 640, 10, 50, 20) GUISetState() ;Show GUI $starturl = "www.yahoo.com" _IENavigate($oIE, $starturl) $bQUIT = False $SecondaryEvent =0; While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_Button_Source MsgBox(0, "GUI Event", "You pressed Source!") _ClickMySource() Case $msg = $GUI_Button_Back or $SecondaryEvent= $GUI_Button_Back MsgBox(0, "GUI Event", "You pressed Back!") $SecondaryEvent =0 Case $msg = $GUI_Button_Stop or $SecondaryEvent= $GUI_Button_Stop MsgBox(0, "GUI Event", "You pressed Stop!") $SecondaryEvent =0 Case $msg = $GUI_Button_Save or $SecondaryEvent= $GUI_Button_Save MsgBox(0, "GUI Event", "You pressed Save!") $SecondaryEvent =0 Case $msg = $GUI_EVENT_CLOSE or $SecondaryEvent= $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEnd Func _ClickMySource() MsgBox(0,"Message","Entered loop") While 1 $SecondaryEvent = GUIGetMsg() Select Case $SecondaryEvent= $GUI_Button_Back ExitLoop Case $SecondaryEvent= $GUI_Button_Stop ExitLoop Case $SecondaryEvent= $GUI_Button_Save ExitLoop Case $SecondaryEvent= $GUI_EVENT_CLOSE ExitLoop EndSelect Sleep(10) ;how can I leave this loop when I click the any of the buttons? WEnd MsgBox(0,"Message","Leaving loop") EndFunc ;==>_ClickMySource Regards, eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code 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