mrmimi 0 Posted December 26, 2006 (edited) #include <GUIConstants.au3> Opt("GUIOnEventMode",4) GuiCreate("alogin", 482, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "stop") ;------BUTTONS------------------------------------ $stop = GUICtrlCreateButton("Exit", 110, 160, 70, 25) GUICtrlSetOnEvent($stop, "stop") $Start = GUICtrlCreateButton("Start", 10, 160, 40, 25) GUICtrlSetOnEvent($Start, "GO") ;------------------------------------- GUISetState() While GuiGetMsg() <> $stop WEnd ;---------FUNCTIONS------------------------ Func stop() ToolTip("i wanna quit ...",470,395) Sleep(500) exit EndFunc func GO() ToolTip("A long cycle ... Stop me pls------------------",500,300) ;-------------long cycle here.....like Sleep(9999999999) - so i need to stop it with "Exit" Button?but how ? ;no HotKeys -only with pressing "Exit" button Sleep(100000000) EndFunc Edited December 26, 2006 by mrmimi Share this post Link to post Share on other sites
mrmimi 0 Posted December 26, 2006 ohh sry.Autoit is not multithreading programm-so i cant break my loop via GUI only with HotKeys ? Share this post Link to post Share on other sites
xcal 2 Posted December 26, 2006 What are you trying to do? You have Opt("GUIOnEventMode",4), but options are 0 or 1. If you were trying to turn that on, GuiGetMsg() is always 0. Your idle loop doesn't contain a sleep(), so you'll be eating up CPU cycles. Try this. I think it's what you want... just tweak it to your needs. expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $doit = False GUICreate('Test', 66, 82) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUICtrlCreateButton('toggle', 10, 10, 46, 26) GUICtrlSetOnEvent(-1, 'toggle') GUICtrlCreateButton('exit', 10, 46, 46, 26) GUICtrlSetOnEvent(-1, 'quit') GUISetState() While 1 Sleep(100) If $doit Then $i = 0 Do $i += 1 ToolTip('Iteration: ' & $i & '/100') Sleep(100) Until $i = 100 Or $doit = False ToolTip('Stopping Loop...') Sleep(1500) $doit = False ToolTip('') EndIf WEnd Func toggle() $doit = Not $doit EndFunc Func quit() ToolTip('Exiting...') Sleep(1500) Exit EndFunc Hide xcal's signature Hide all signatures How To Ask Questions The Smart Way Share this post Link to post Share on other sites
mrmimi 0 Posted December 26, 2006 Thanks a lot ! Ill try Share this post Link to post Share on other sites