pete Posted October 14, 2008 Share Posted October 14, 2008 Hi all, I have a small window with two buttons, one which starts the script, and the other which is supposed to stop it. The Start button starts a function, which just just spits out some text to notepad in a For/Next loop. The Stop button sets a flag to False, which I would then stop the Start button function. The problem is, GUIGetMsg() doesn't appear to be functioning within the sub loop, at least my Stop case never seems to get called, and my window won't close. Here's an abbreviated version of the code: CODEWhile 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $Button_1 If $isactive = True Then For $x = 1 To $max ; do something Next EndIf Case $msg = $Button_2 $isactive = False MsgBox(0, 'Testing', 'Button 2 was pressed') EndSelect WEnd I'm not quite sure what I'm missing here. I was hoping maybe someone could help me out? Thanks, Pete Link to comment Share on other sites More sharing options...
Rental Posted October 15, 2008 Share Posted October 15, 2008 Hi all, I have a small window with two buttons, one which starts the script, and the other which is supposed to stop it. The Start button starts a function, which just just spits out some text to notepad in a For/Next loop. The Stop button sets a flag to False, which I would then stop the Start button function. The problem is, GUIGetMsg() doesn't appear to be functioning within the sub loop, at least my Stop case never seems to get called, and my window won't close. Here's an abbreviated version of the code: I'm not quite sure what I'm missing here. I was hoping maybe someone could help me out? Thanks, Pete ok so let me try to understand what you want, you have a gui that has 2 buttons, one staers script other stops, your problem is when you click the stop button it doesnt stop right? if i got this right then try instead of For/next try to do/until while 1 If $isactive = True Then do ;you script here until $isactive = false wend while 2 $msg = guigetmsg() select case $msg = $GUI_EVENT_CLOSE case $msg = $buttonstop $isactive= false endw this is just put together from what i thought ya meant so i dont know if its what ur looking for Link to comment Share on other sites More sharing options...
pete Posted October 15, 2008 Author Share Posted October 15, 2008 That's essentially right, two buttons, one starts the loop, the other to stop. It seems, even with your code, that the stop button never gets called. I put a msgbox in there, and it's ignored. The X to close the window in the top right, also won't work, I have to manually kill the process in order to get the script to stop running. Link to comment Share on other sites More sharing options...
Bert Posted October 15, 2008 Share Posted October 15, 2008 try changing $isactive = False to if $isactive = False then MsgBox(0, 'Testing', 'Button 2 was pressed') endif The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
martin Posted October 15, 2008 Share Posted October 15, 2008 Hi all, I have a small window with two buttons, one which starts the script, and the other which is supposed to stop it. The Start button starts a function, which just just spits out some text to notepad in a For/Next loop. The Stop button sets a flag to False, which I would then stop the Start button function. The problem is, GUIGetMsg() doesn't appear to be functioning within the sub loop, at least my Stop case never seems to get called, and my window won't close. Here's an abbreviated version of the code: CODEWhile 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $Button_1 If $isactive = True Then For $x = 1 To $max ; do something Next EndIf Case $msg = $Button_2 $isactive = False MsgBox(0, 'Testing', 'Button 2 was pressed') EndSelect WEnd I'm not quite sure what I'm missing here. I was hoping maybe someone could help me out? Thanks, Pete Something like this should do it. While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $Button_1 If $isactive = True Then For $x = 1 To $max ; do something $msg = GuiGetMsg() If $msg = $Button_2 Then ConsoleWrite"Button_2 pressed" & @CR) $Active = False ExitLoop EndIf Next EndIf Case $msg = $Button_2 $isactive = False MsgBox(0, 'Testing', 'Button 2 was pressed') EndSelect WEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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