Altor Posted November 28, 2016 Posted November 28, 2016 Hi all My problem is that I have no way to work with buttons in a while loop When i run the form i can exit well clicking a close main window and olso if i click in a exit button but if i start the apllication whith a Start button execute a loop for view a random numbers and then i can't stop the rogram and i can't not exit with a Exit button. I think the problem is in the use of events but i can not find the solution.... Thank's to all The exemple is this: expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Opt("GUIOnEventMode", 1) $random_numbers = GUICreate("Random numbers",351,171,-1,-1,-1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "close") $lavel_number = GUICtrlCreateLabel("",117,36,98,26,BitOr($SS_CENTER,$SS_CENTERIMAGE),$WS_EX_STATICEDGE) GUICtrlSetBkColor(-1,"0xFFFFFF") $start = GUICtrlCreateButton("Start",34,95,100,30,-1,-1) GUICtrlSetOnEvent(-1,"start") $stop = GUICtrlCreateButton("Pause",182,95,100,30,-1,-1) GUICtrlSetOnEvent(-1,"pause") $exit = GUICtrlCreateButton("Exit",112,136,100,30,-1,-1) GUICtrlSetOnEvent(-1,"close") GUISetState(@SW_SHOW) While 1 Sleep (50) Wend Func start() While 1 Sleep(100) Local $a = Random(1,10,1) GUICtrlSetData($lavel_number,$a) WEnd EndFunc Func pause() EndFunc func close() exit EndFunc
Developers Jos Posted November 28, 2016 Developers Posted November 28, 2016 Something like this ? : expandcollapse popup#include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> Opt("GUIOnEventMode", 1) $random_numbers = GUICreate("Random numbers", 351, 171, -1, -1, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "close") $lavel_number = GUICtrlCreateLabel("", 117, 36, 98, 26, BitOR($SS_CENTER, $SS_CENTERIMAGE), $WS_EX_STATICEDGE) GUICtrlSetBkColor(-1, "0xFFFFFF") $start = GUICtrlCreateButton("Start", 34, 95, 100, 30, -1, -1) GUICtrlSetOnEvent(-1, "start") $stop = GUICtrlCreateButton("Pause", 182, 95, 100, 30, -1, -1) GUICtrlSetOnEvent(-1, "pause") $exit = GUICtrlCreateButton("Exit", 112, 136, 100, 30, -1, -1) GUICtrlSetOnEvent(-1, "close") GUISetState(@SW_SHOW) Global $OptChoosen = 0 While 1 Sleep(50) While $OptChoosen = 1 Sleep(100) Local $a = Random(1, 10, 1) GUICtrlSetData($lavel_number, $a) WEnd WEnd Func start() $OptChoosen = 1 EndFunc ;==>start Func pause() $OptChoosen = 0 EndFunc ;==>pause Func close() Exit EndFunc ;==>c Jos Altor 1 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.
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