shadesdude Posted December 7, 2006 Posted December 7, 2006 This is just some simplified code that I was testing if an event trigger would kick out of a loop. This reflects a program I am working on however the Click1() functing has some pretty complex nested loops (I am used to asm ). #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("MY GUI") $ViewImageButton = GUICtrlCreateButton("Click 1", 178, 350, 171, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "Click1") $ViewImageButton = GUICtrlCreateButton("Click 2", 178, 300, 171, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "Click2") GUISetState() While 1 Sleep(10) WEnd Func Click1() While(1) WEnd EndFunc Func Click2() MsgBox(0x0,"test", "it worked") EndFunc Now lets say I change it to... $stop = 0 Func Click1() While(Not $stop) WEnd EndFunc Func Click2() $stop = 1 MsgBox(0x0,"test", "it worked") EndFunc I'm guessing that won't work either because it will never call the Click2() function. Anyway is there anyone who has a good way to make it kick out of the loop?
Valuater Posted December 7, 2006 Posted December 7, 2006 (edited) maybe.. #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Dim $click GUICreate("MY GUI") $ViewImageButton = GUICtrlCreateButton("Click 1", 178, 350, 171, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "Click1") $ViewImageButton = GUICtrlCreateButton("Click 2", 178, 300, 171, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetOnEvent(-1, "Click2") GUISetState() While 1 Sleep(10) While $click ToolTip("Press Click1 to exit", 10, 10, "thanks Valuater", 1) Sleep(100) WEnd ToolTip("") WEnd Func Click1() $click = Not $click EndFunc ;==>Click1 Func Click2() MsgBox(0x0, "test", "it worked") EndFunc ;==>Click2 8) Edited December 7, 2006 by Valuater
shadesdude Posted December 8, 2006 Author Posted December 8, 2006 Very impressive (I especially enjoyed the tooltip) It wasn't exactly what I needed but it set me on the right track . Now I need to think of a way to pause my loops and have it resume from the same spot so the user can access settings and whatnot. Autoit dosen't have access to a stack pointer does it. o.0
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