qazwsx Posted July 14, 2007 Share Posted July 14, 2007 I am trying to do something until a button on a Gui is pressed. expandcollapse popup#include <GuiConstants.au3> #include <misc.au3> #include <array.au3> $Form1 = GUICreate("Recorder", 192, 60, 193, 115) $Button1 = GUICtrlCreateButton("Begin Recording...", 16, 8, 155, 41, 0) GUISetState(@SW_SHOW) $count = 0 While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $GUI_EVENT_CLOSE Exit Case $nmsg = $Button1 GUICtrlDelete ($Button1) $Button2 = GUICtrlCreateButton("Stop Recording", 16, 8, 155, 41, 0) ExitLoop Case Else EndSelect WEnd While 1 $nmsg2 = GUIGetMsg () Select Case $nmsg2 = $GUI_EVENT_CLOSE Case Else Do $count =+1 Until $nmsg2 = $Button2 GUIDelete () ExitLoop(2) EndSelect Wend MsgBox (0, "", $count) here is my attempt but when i press stop the Gui does not go away and the msgbox doesn't popup. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 14, 2007 Developers Share Posted July 14, 2007 (edited) it will get stuck in the Do-Until loop. try: While 1 $nmsg2 = GUIGetMsg() Select Case $nmsg2 = $GUI_EVENT_CLOSE Case $nmsg2 = $Button2 GUIDelete() ExitLoop Case Else $count = +1 EndSelect WEnd Edited July 14, 2007 by JdeB 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...
Zedna Posted July 14, 2007 Share Posted July 14, 2007 #include <GuiConstants.au3> #include <misc.au3> #include <array.au3> $Form1 = GUICreate("Recorder", 192, 60, 193, 115) $Button1 = GUICtrlCreateButton("Begin Recording...", 16, 8, 155, 41, 0) GUISetState(@SW_SHOW) $count = 0 While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $GUI_EVENT_CLOSE Exit Case $nmsg = $Button1 GUICtrlDelete ($Button1) $Button2 = GUICtrlCreateButton("Stop Recording", 16, 8, 155, 41, 0) ExitLoop Case Else EndSelect WEnd While 1 $nmsg2 = GUIGetMsg () Select Case $nmsg2 = $GUI_EVENT_CLOSE Case $nmsg2 = $Button2 GUIDelete () ExitLoop Case Else $count += 1 EndSelect Wend MsgBox (0, "", $count) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
qazwsx Posted July 14, 2007 Author Share Posted July 14, 2007 Ohh alright Thx for your help guys Link to comment Share on other sites More sharing options...
Zedna Posted July 14, 2007 Share Posted July 14, 2007 It can be done in one loop: #include <GuiConstants.au3> $Form1 = GUICreate("Recorder", 192, 60, 193, 115) $Button1 = GUICtrlCreateButton("Begin Recording...", 16, 8, 155, 41, 0) GUISetState(@SW_SHOW) $count = 0 $recoding = False While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $GUI_EVENT_CLOSE Exit Case $nmsg = $Button1 If Not $recoding Then $recoding = True $Button2 = GUICtrlSetData($Button1, "Stop Recording") Else ExitLoop EndIf Case Else If $recoding Then $count += 1 EndSelect WEnd MsgBox (0, "", $count) Resources UDF ResourcesEx UDF AutoIt Forum Search 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