Bilan Posted December 18, 2006 Posted December 18, 2006 I'm just a beginner when it comes to programming. I have this problem: I have a GUI with several buttons, one of these buttons calls on a loop function that doesnt stop. Another button should let it stop though, how do I do that? I don't understand how to let the GUI still function when some other processes in the same program are running. Thanks.
xcal Posted December 18, 2006 Posted December 18, 2006 (edited) A number of ways to do it. I made this for someone else, but maybe it'll help (or confuse) you. expandcollapse popup#include <GUIConstants.au3> Opt('GUIOnEventMode', 1) $paused = True $new = True GUICreate('Toggle', 160, 206) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUICtrlCreateButton('Toggle', 30, 30, 100, 26) GUICtrlSetOnEvent(-1, 'toggle') GUICtrlCreateButton('Other Btn', 30, 86, 100, 26) GUICtrlSetOnEvent(-1, 'otherfunc') $label = GUICtrlCreateLabel('Weeeeee', 30, 147, 100, 26) GUISetState() While 1 Sleep(50) If Not $paused Then runloop() WEnd Func runloop() ToolTip('running') EndFunc Func otherfunc() $new = Not $new If $new Then GUICtrlSetData($label, 'Some new text') Else GUICtrlSetData($label, 'Lalalala') EndIf EndFunc Func toggle() $paused = Not $paused ToolTip('') EndFunc Func quit() Exit EndFunc Edited December 18, 2006 by xcal How To Ask Questions The Smart Way
jpm Posted December 18, 2006 Posted December 18, 2006 @xcal I assume that Bilan cannot produce a code like the one you submit as your is not really looping inside the called function. just change your runloop function toFunc runloop() While 1 Sleep(10) Wend EndFunc As AutoIT is not a multithreaded program your solution is the only way to interrupt the execution. Just because you don't loop in the function ... @Bilan No solution unless you transform your program to work a @xcal one
Bilan Posted December 18, 2006 Author Posted December 18, 2006 Ah I found some other way, changed the plan . Thanks anyway.
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