Lyee Posted February 25, 2017 Share Posted February 25, 2017 (edited) Hello i have got a problem.. I have loop with the basic lines and plus one button.. If is button clicked, it start function and there's my problem.. When I have in my function Sleep command it freeze all buttons.. and GUI is useless then.. What's wrong? Which command can fix it? Is Sleep() correct with GUI? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $frm = GUICreate("Form1", 258, 65, 192, 132) $startbtn = GUICtrlCreateButton("START", 16, 16, 75, 25) $txt = GUICtrlCreateLabel("Program is waiting", 112, 20, 200, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $startbtn $sbtn = GUICtrlRead($startbtn) If $sbtn = "START" Then GUICtrlSetData($startbtn, "STOP") GUICtrlSetData($txt, "Program in progress...") _Main() Else GUICtrlSetData($startbtn, "START") GUICtrlSetData($txt, "Program is waiting") EndIf EndSwitch WEnd Func _Main() Sleep(30000) EndFunc ;==>_Main Edited February 25, 2017 by Lyee Link to comment Share on other sites More sharing options...
Developers Jos Posted February 25, 2017 Developers Share Posted February 25, 2017 There is nothing "wrong" as your gui message loop is interrupted by the call to the _Main() FUNC. So it is really an design issue. One thing to look for is to use the event mode for the GUI which allows for a alternative design. 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. 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