duzers 0 Posted May 17, 2010 (edited) Hello, I want to Start script and Exit script with GUI, but when I click Start, button Exit (X) not work. how can I stop the running script? I used OnEventmode. It is sample code: #include <GUIConstantsEx.au3> Sleep(1000) Opt("GUIOnEventMode", 1) GUICreate("OnEvent test", 230, 120) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitProgram") $button = GUICtrlCreateButton("Start", 10, 40, 100) GUICtrlSetOnEvent($button , "button") GUISetState(@SW_SHOW) While 1 sleep(40) WEnd Func button() sleep(20000) ;work... ;work... ;work firefox with FF, autologins, writes, sets other things... endfunc Func Exitprogram() MsgBox(0, "exit", "exit") Exit EndFunc thx Edited May 17, 2010 by duzers Share this post Link to post Share on other sites
Realm 18 Posted May 17, 2010 (edited) duzers, I'm not sure what your attempting, and I'm no pro, but I think this is what your looking for. Try this #include <GUIConstantsEx.au3> Sleep(1000) Opt("GUIOnEventMode", 1) GUICreate("OnEvent test", 230, 120) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitProgram") $button = GUICtrlCreateButton("Start", 10, 40, 100) GUICtrlSetOnEvent($button , "button") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button button() EndSwitch WEnd Func button() sleep(20000) ;work... ;work... ;work firefox with FF, autologins, writes, sets other things... endfunc Edited May 17, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Share this post Link to post Share on other sites
duzers 0 Posted May 17, 2010 No, It's not this. I want exit even if sleep(20000) work. Share this post Link to post Share on other sites
Realm 18 Posted May 17, 2010 (edited) Sorry, I forgot to take out the on event code stuff, this will work now: #include <GUIConstantsEx.au3> Sleep(1000) GUICreate("OnEvent test", 230, 120) $button = GUICtrlCreateButton("Start", 10, 40, 100) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button button() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func button() sleep(20000) ;work... ;work... ;work firefox with FF, autologins, writes, sets other things... endfunc Edited May 17, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Share this post Link to post Share on other sites
Jos 2,211 Posted May 17, 2010 (edited) Example that should work: #include <GUIConstantsEx.au3> Global $StartPressed = 0 Opt("GUIOnEventMode", 1) GUICreate("OnEvent test", 230, 120) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitProgram") $button = GUICtrlCreateButton("Start", 10, 40, 100) GUICtrlSetOnEvent($button, "ButtonPressed") GUISetState(@SW_SHOW) ; While 1 If $StartPressed Then $StartPressed = 0 Button() EndIf Sleep(10) WEnd ; Func ButtonPressed() $StartPressed = 1 EndFunc ;==>ButtonPressed ; Func button() Sleep(20000) ;work... ;work... ;work firefox with FF, autologins, writes, sets other things... EndFunc ;==>button Func ExitProgram() Exit EndFunc ;==>ExitProgram Edited May 17, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
duzers 0 Posted May 17, 2010 This is it!. Many thanks. This should be a standard feature in AutoIt. Share this post Link to post Share on other sites
GEOSoft 67 Posted May 17, 2010 This is it!. Many thanks.This should be a standard feature in AutoIt.It is, you just have to learn how to use it. GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!" Share this post Link to post Share on other sites
duzers 0 Posted May 18, 2010 Is there a sample way with this example to Pause/Go script with etc. button2 ? Share this post Link to post Share on other sites
Jos 2,211 Posted May 18, 2010 (edited) Is there a sample way with this example to Pause/Go script with etc. button2 ?Everything is possible when you set your mind to it.Just think about how to get this done ... The hotkeys could be an option but also a button as long as you ensure you read the GUI messages.Jos Edited May 18, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites