AlmarM Posted January 11, 2008 Share Posted January 11, 2008 Why doesnt this work? #include <GUIConstants.au3> $GUI = GUICreate("Value Changer", 100, 100, -1, -1) $Label = GUICtrlCreateLabel("", 10, 10, 30, 30) $Button = GUICtrlCreateButton("Change Value", 10, 40) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button For $i = 1 To 100 Step 1 Next GUICtrlSetData($Label, $i) EndSelect WEnd If I press Change Value it will set the Label to: 101 Whats wrong I think its just a newbie thing Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2008 Developers Share Posted January 11, 2008 The value of $i will be 101 when the for-next loop is ended ... so what is it you want it to do ? by the way, please shorten your Sig some... save us all the scrolling effort... 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...
AlmarM Posted January 11, 2008 Author Share Posted January 11, 2008 (edited) Done with sig And I think I need to place ExitLoop somewhere? EDIT: I edited my script. #include <GUIConstants.au3> $GUI = GUICreate("Value Changer", 100, 100, -1, -1) $Label = GUICtrlCreateLabel("", 10, 10, 30, 30) $Button = GUICtrlCreateButton("Change Value", 10, 40) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button For $i = 1 To 100 Step 1 GUICtrlSetData($Label, $i) Next EndSelect WEnd He'll set the Value of the label to 100 from 1 realy fast... Its like 1 50 100 Thats almost what I see Edited January 11, 2008 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2008 Developers Share Posted January 11, 2008 I have no idea what you want so cannot answer.... First define what it is you want to do when the button is pressed .. 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...
AlmarM Posted January 11, 2008 Author Share Posted January 11, 2008 (edited) The Label = Empty If u press the Button it will GUICtrlSetData the Label to 1 Then 2 Then 3 etc untill 100 So each timie u press the Button the value will be +1 Edited January 11, 2008 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2008 Developers Share Posted January 11, 2008 ok ... add a sleep in there to give it time to repaint... something like: For $i = 1 To 100 Step 1 GUICtrlSetData($Label, $i) Sleep(50) Next 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...
AlmarM Posted January 11, 2008 Author Share Posted January 11, 2008 Ty ^^ Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2008 Developers Share Posted January 11, 2008 (edited) So each timie u press the Button the value will be +1ahh change of requirements No need for the loop then ...just: GUICtrlSetData($Label, GUICtrlRead($Label) + 1) Edited January 11, 2008 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. Link to comment Share on other sites More sharing options...
AlmarM Posted January 11, 2008 Author Share Posted January 11, 2008 (edited) Ye or, #include <GUIConstants.au3> $GUI = GUICreate("Value Changer", 100, 100, -1, -1) $Label = GUICtrlCreateLabel("", 10, 10, 30, 30) $Button = GUICtrlCreateButton("Change Value", 10, 40) GUISetState() $i = 0 While $i < 100 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button $i = $i +1 GUICtrlSetData($Label, $I) EndSelect WEnd Edited January 11, 2008 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
i542 Posted January 11, 2008 Share Posted January 11, 2008 Ye or, #include <GUIConstants.au3> $GUI = GUICreate("Value Changer", 100, 100, -1, -1) $Label = GUICtrlCreateLabel("", 10, 10, 30, 30) $Button = GUICtrlCreateButton("Change Value", 10, 40) GUISetState() $i = 0 While $i < 100 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button $i = $i +1 GUICtrlSetData($Label, $I) EndSelect WEndfast learner, congrats I can do signature me. Link to comment Share on other sites More sharing options...
themax90 Posted January 14, 2008 Share Posted January 14, 2008 Ye or, #include <GUIConstants.au3> $GUI = GUICreate("Value Changer", 100, 100, -1, -1) $Label = GUICtrlCreateLabel("", 10, 10, 30, 30) $Button = GUICtrlCreateButton("Change Value", 10, 40) GUISetState() $i = 0 While $i < 100 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button $i = $i +1 GUICtrlSetData($Label, $I) EndSelect WEnd Yes this works as well but provides an unneeded variable and an extra line. Congratz on learning a little more on repetition. Don't forget to apply it to other repetitive actions as an option as well from now on and happy scripting . 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